Repository navigation
Conversation
Code Review Agent Run #495cddActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| except QueryObjectValidationError as exc: | ||
| return self.response_400(message=sanitize_error_message(exc.message)) |
There was a problem hiding this comment.
Suggestion: The new handling only covers _get_data_response, but the GLOBAL_ASYNC_QUERIES path calls command.execute(force_cached=True) directly in _run_async, where only ChartDataCacheLoadError is caught. If execution-time validation in get_payload_result() raises QueryObjectValidationError during the cache lookup, it escapes to Flask and returns HTTP 500 instead of 400. Add equivalent handling to the async cache-hit path before scheduling the background job. [incomplete implementation]
Severity Level: Major ⚠️
- ❌ Async chart requests can return HTTP 500 for invalid queries.
- ⚠️ Clients receive server errors instead of validation feedback.
- ⚠️ GLOBAL_ASYNC_QUERIES cache-hit handling remains inconsistent.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/charts/data/api.py
**Line:** 649:650
**Comment:**
*Incomplete Implementation: The new handling only covers `_get_data_response`, but the `GLOBAL_ASYNC_QUERIES` path calls `command.execute(force_cached=True)` directly in `_run_async`, where only `ChartDataCacheLoadError` is caught. If execution-time validation in `get_payload_result()` raises `QueryObjectValidationError` during the cache lookup, it escapes to Flask and returns HTTP 500 instead of 400. Add equivalent handling to the async cache-hit path before scheduling the background job.
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|
The flagged issue is correct. The superset/charts/data/api.py |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43081 +/- ##
==========================================
- Coverage 84.63% 83.97% -0.67%
==========================================
Files 3069 3050 -19
Lines 205446 203375 -2071
Branches 48306 47373 -933
==========================================
- Hits 173879 170774 -3105
- Misses 28277 29312 +1035
+ Partials 3290 3289 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
92c4854 to
45b643a
Compare
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #2cd5ccActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
Richard's agent here: I found one blocking gap at 45b643a.
-
With GLOBAL_ASYNC_QUERIES enabled, _run_async() still calls command.execute(force_cached=True) while catching only ChartDataCacheLoadError. QueryObjectValidationError can therefore still reach the generic handler as HTTP 500. Could we add equivalent 400 handling to that cache lookup?
-
Wdyt about adding targeted regression cases for both _get_data_response() and _run_async()? The changed line currently has no patch coverage, and the two test paths listed in the PR description do not exist on this head; the relevant modules are tests/unit_tests/charts/test_chart_data_api.py and tests/integration_tests/charts/data/api_tests.py.
With GLOBAL_ASYNC_QUERIES enabled, `_run_async()` probes the cache with `command.execute(force_cached=True)` but only caught `ChartDataCacheLoadError`. Query errors raised during that lookup fell through to the global error handlers, so `ChartDataQueryFailedError` returned HTTP 500 and validation errors skipped the error-message sanitization applied on the sync path. Handle `ChartDataQueryFailedError`, `SemanticLayerQueryRejectedError` and `QueryObjectValidationError` on the cache lookup the same way `_get_data_response()` does: a sanitized 400 response, with no async job enqueued. Add unit and integration regression tests covering both the sync (`_get_data_response`) and async cache-lookup (`_run_async`) paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
45b643a to
ea38b89
Compare
|
@richardfogaca thanks for the review. I rebased onto master and addressed both points in ea38b89: Async cache-hit path: When I checked before/after against current master, the behavior was a bit different from what we'd both assumed. Tests: you were right that the test paths in the old description didn't exist. The tests are now:
With Rebase note: the original |
|
@richardfogaca re-requesting your review — the async cache-lookup fix you flagged on 8/17 is in, both regression tests you asked for are added, and CI is fully green on the current head. Would appreciate a re-review when you have a moment. |
|
Hi @rusackas — @richardfogaca requested changes back in August and hasn't had a chance to revisit despite a follow-up ping. CI is green and the PR is otherwise ready. Would you be able to take a look and review when you get a chance? Happy to address any feedback. Thanks! |
rusackas
left a comment
There was a problem hiding this comment.
Thanks @eschutho, LGTM!
@richardfogaca I believe both of your points from August are covered now (the async cache lookup and the regression tests), so it'd be great if you could clear the block when you get a sec.
SUMMARY
With
GLOBAL_ASYNC_QUERIESenabled,ChartDataRestApi._run_async()first probes the cache withcommand.execute(force_cached=True), but only caughtChartDataCacheLoadError. Any other query error raised during that lookup escaped to Flask's global error handlers instead of getting the handling the sync path in_get_data_response()applies:ChartDataQueryFailedError(CommandException,status = 500){"errors": [...]}{"message": ...}QueryObjectValidationError(status = 400){"errors": [...]}for JSON clients, the HTML error page forAccept: text/html{"message": ...}SemanticLayerQueryRejectedError(status = 400){"errors": [...]}{"message": ...}ChartDataQueryFailedErroris the case users can actually hit. A cached entry that's missing filter metadata is treated as a cache miss, so the "cache-only" probe runs the query live, and a failing query raised 500. The other two exceptions are caught for parity with the sync path. Guests already received a generic error message before this change and still do.This PR catches the same exceptions in the cache-lookup block that
_get_data_response()catches (ChartDataQueryFailedError,SemanticLayerQueryRejectedError,QueryObjectValidationError). It returns the same sanitized 400 response and doesn't enqueue an async job.The original change on this PR (adding
QueryObjectValidationErrorto_get_data_response()) has since landed on master via #45110, so after rebasing, this PR only covers the async path plus regression tests for both paths.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (backend only)
TESTING INSTRUCTIONS
New regression tests:
tests/unit_tests/charts/test_chart_data_api.pytest_get_data_response_returns_400_for_query_object_validation_errortest_run_async_returns_400_when_cache_lookup_rejects_the_query(parametrized over all three exceptions; asserts 400, sanitized message,force_cached=True, no task submitted)tests/integration_tests/charts/data/api_tests.py(module-level tests usingphysical_query_context, so they run even though theTestPostChartDataApiclass is skipped)test_chart_data_query_object_validation_error__400(sync path, end to end)test_chart_data_async_cache_lookup_query_error__400(GLOBAL_ASYNC_QUERIES=True,async_mode=True,force=False; parametrized overQueryObjectValidationErrorandChartDataQueryFailedError)pytest tests/unit_tests/charts/test_chart_data_api.py pytest tests/integration_tests/charts/data/api_tests.py -k "query_object_validation_error or cache_lookup_query_error"I checked the before/after locally by reverting only
superset/charts/data/api.py. The new_run_asyncunit tests and both async integration cases fail without the fix:ChartDataQueryFailedErrorreturns 500, andQueryObjectValidationErrorreturns the genericerrors[]body. With the fix, they pass.ADDITIONAL INFORMATION
GLOBAL_ASYNC_QUERIES(for the async path)🤖 Generated with Claude Code