EnxDev commented on code in PR #38744:
URL: https://github.com/apache/superset/pull/38744#discussion_r2974702629


##########
superset/charts/data/api.py:
##########
@@ -250,20 +250,67 @@ def data(  # noqa: C901
             json_body = request.json
         elif request.form.get("form_data"):
             # CSV export submits regular form data
-            with contextlib.suppress(TypeError, json.JSONDecodeError):
+            try:
                 json_body = json.loads(request.form["form_data"])
+            except (TypeError, json.JSONDecodeError):
+                logger.error(
+                    "Failed to parse form_data JSON: "
+                    "content_type=%s, content_length=%s, form_data_length=%s, "
+                    "referrer=%s",
+                    request.content_type,
+                    request.content_length,
+                    len(request.form.get("form_data", "")),
+                    request.referrer,
+                )
         if json_body is None:
+            logger.error(
+                "Chart data request rejected: json_body is None. "
+                "is_json=%s, content_type=%s, content_length=%s, "
+                "has_form_data=%s, referrer=%s",
+                request.is_json,
+                request.content_type,
+                request.content_length,
+                bool(request.form.get("form_data")),
+                request.referrer,
+            )

Review Comment:
   When `form_data` is present but unparseable, this block fires after the 
except above has already logged. A single parse failure produces two 
logger.error entries in the log, which could be confusing when correlating 
events.



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