bito-code-review[bot] commented on code in PR #44036:
URL: https://github.com/apache/superset/pull/44036#discussion_r3977013998


##########
superset/security/api.py:
##########
@@ -265,6 +266,12 @@ def guest_token(self) -> Response:
             return self.response(200, token=token)
         except EmbeddedDashboardNotFoundError as error:
             return self.response_400(message=error.message)
+        except EmbeddedDashboardAccessDeniedError as error:
+            # The minting principal is not entitled to the dashboard being
+            # scoped (see validate_guest_token_resources): an authorization
+            # denial, not a server fault, so answer 403 rather than letting
+            # @safe turn it into a logged 500.
+            return self.response_403(message=error.message)
         except ValidationError as error:

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>response_403 rejects message kwarg</b></div>
   <div id="fix">
   
   `BaseApi.response_403(self)` in flask-appbuilder 5.2.2 takes no `message` 
argument (it hardcodes "Forbidden"), unlike `response_400(self, message)`. 
Passing `message=error.message` raises `TypeError`, which `@safe` converts to a 
500 — defeating the intended 403. Use `self.response(403, 
message=error.message)`.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
           except EmbeddedDashboardAccessDeniedError as error:
               # The minting principal is not entitled to the dashboard being
               # scoped (see validate_guest_token_resources): an authorization
               # denial, not a server fault, so answer 403 rather than letting
               # @safe turn it into a logged 500.
               return self.response(403, message=error.message)
           except ValidationError as error:
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #a24a1d</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to