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


##########
superset/views/error_handling.py:
##########
@@ -74,12 +79,20 @@ def json_error_response(
 ) -> FlaskResponse:
     payload = payload or {}
 
+    if isinstance(error_details, SupersetError):
+        error_details = [error_details]
+
     if isinstance(error_details, list):
-        payload["errors"] = [dataclasses.asdict(error) for error in 
error_details]
-    elif isinstance(error_details, SupersetError):
-        payload["errors"] = [dataclasses.asdict(error_details)]
+        payload["errors"] = [
+            dataclasses.asdict(error)
+            for error in sanitize_superset_errors(error_details)
+        ]
     elif isinstance(error_details, str):
-        payload["error"] = error_details
+        payload["error"] = (
+            error_details
+            if status in SAFE_STATUSES
+            else sanitize_error_message(error_details)
+        )

Review Comment:
   The comment is valid. Using HTTP status alone is too broad: a `404` can 
represent either a safe routing/not-found response or a backend/database error 
containing catalog metadata. Thus, `SAFE_STATUSES` can leak information the PR 
intends to redact.
   
   A minimal fix is to remove the status-based bypass and sanitize all 
bare-string messages for guest users:
   
   ```python
   elif isinstance(error_details, str):
       payload["error"] = sanitize_error_message(error_details)
   ```
   
   If specific authorization or routing messages must remain visible, they 
should be converted to structured `SupersetError` instances with allowlisted 
`error_type` values. This preserves the existing type-based allowlist and 
ensures new or ambiguous bare-string errors are redacted by default. The 
current `SAFE_STATUSES` constant and related status handling can then be 
removed, along with tests that expect arbitrary `403`/`404` strings to survive.



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