codeant-ai-for-open-source[bot] commented on code in PR #42643:
URL: https://github.com/apache/superset/pull/42643#discussion_r3691480576


##########
superset/views/error_handling.py:
##########
@@ -171,6 +171,21 @@ def show_superset_errors(ex: SupersetErrorsException) -> 
FlaskResponse:
         logger.warning("SupersetErrorsException", exc_info=True)
         return json_error_response(ex.errors, status=ex.status)
 
+    @app.errorhandler(SupersetException)
+    def show_superset_exception(ex: SupersetException) -> FlaskResponse:
+        logger_func, _ = get_logger_from_status(ex.status)
+        logger_func(ex.message, exc_info=True)
+        return json_error_response(
+            [
+                SupersetError(
+                    message=ex.message,
+                    error_type=SupersetErrorType.GENERIC_BACKEND_ERROR,
+                    level=get_error_level_from_status(ex.status),
+                ),

Review Comment:
   **Suggestion:** Content negotiation is bypassed for every 
`SupersetException`. Previously these exceptions reached 
`show_unexpected_exception`, which served Superset's `500.html` page for 
non-debug browser requests accepting HTML; this handler always returns JSON, 
changing browser-facing error responses. Preserve the existing HTML behavior 
for HTML requests or route only API requests through the JSON response. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ HTML clients receive JSON error payloads.
   - ⚠️ Branded 500-page rendering is bypassed.
   - ⚠️ Content negotiation differs across exception classes.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3e5d0911d95b4901842701f9d7050dd7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3e5d0911d95b4901842701f9d7050dd7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/views/error_handling.py
   **Line:** 180:184
   **Comment:**
        *Api Mismatch: Content negotiation is bypassed for every 
`SupersetException`. Previously these exceptions reached 
`show_unexpected_exception`, which served Superset's `500.html` page for 
non-debug browser requests accepting HTML; this handler always returns JSON, 
changing browser-facing error responses. Preserve the existing HTML behavior 
for HTML requests or route only API requests through the JSON response.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42643&comment_hash=7d66c62359fa0bc295310b6db4a5b0f8324a87c6e9dca85e58b3b56cf5c45e41&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42643&comment_hash=7d66c62359fa0bc295310b6db4a5b0f8324a87c6e9dca85e58b3b56cf5c45e41&reaction=dislike'>👎</a>



-- 
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