Repository navigation
Conversation
Code Review Agent Run #05e3ffActionable 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #42410 +/- ##
==========================================
- Coverage 79.04% 78.98% -0.07%
==========================================
Files 2877 2877
Lines 165371 165393 +22
Branches 38215 38211 -4
==========================================
- Hits 130723 130634 -89
- Misses 32186 32279 +93
- Partials 2462 2480 +18
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:
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR hardens chart data post-processing error handling so malformed post_processing inputs surface as validation errors (400) instead of unhandled exceptions (500).
Changes:
- Fixes
selectpost-processing validation forexclude, aligning decorator args and preventing pandasKeyErrors. - Fixes i18n placeholder mismatch so unsupported operations correctly raise
InvalidPostProcessingError. - Adds regression tests covering unsupported/missing
operationand invalidexcludescenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit_tests/queries/query_object_test.py | Adds regression tests for exec_post_processing invalid operation inputs. |
| tests/unit_tests/pandas_postprocessing/test_select.py | Adds regression tests ensuring invalid exclude becomes a validation error. |
| superset/utils/pandas_postprocessing/select.py | Fixes validation decorator arg mismatch and adds runtime validation for exclude after columns projection. |
| superset/common/query_object.py | Fixes gettext placeholder kwarg so unsupported operations raise the intended exception. |
rusackas
left a comment
There was a problem hiding this comment.
Verified both root causes (the "drop" vs exclude decorator mismatch, and type=operation vs %(operation)s) and the fix plus tests look right. Copilot's two open nits (select.py:60 wanting the specific missing column names in the message, query_object_test.py:392 preferring str(excinfo.value) over .message) are fair polish but not worth blocking on. Let me know if you intend to tackle those.
|
Thanks for the review @rusackas — yes, tackled both. Pushed a follow-up. Copilot's Done, and it uses the interpolation style already present in the package ( if missing := [column for column in exclude if column not in df_select.columns]:
raise InvalidPostProcessingError(
_(
"Referenced columns not available in DataFrame: %(columns)s",
columns=", ".join(missing),
)
)One wrinkle worth flagging, since it means the nit is only partly addressable I left the decorator's message alone deliberately: it's shared by every operation Copilot's Done, now One thing I noticed while verifying The two fixes overlap more than the PR description implies. Because my guard I'd still keep the decorator change — Verified against the pinned toolchain: ruff 0.9.7, mypy 1.15.0 with the hook's |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Good catch, this one is real — fixed and pushed. @rusackas heads-up, since you'd already approved: this is a third commit fixing an
The scalar form is supported — exclude = list(scalar_to_sequence(exclude))Two corrections to the report, in both directions: It's older than the comment suggests. The regression came in with the first Before this branch, But "Major" overstates the reach. It isn't reachable through the chart-data
|
Code Review Agent Run #b9b797Actionable 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 |
…ng-validation-errors # Conflicts: # tests/unit_tests/queries/query_object_test.py
|
Rebased onto master to clear the conflict with #42927. The collision was purely textual: both that PR and this one append tests to the end of The two changes are complementary rather than overlapping. #42927 drops options an operation no longer accepts, and deliberately leaves a missing or unknown
That is the error this PR fixes, it was interpolating Verified after the merge: 369 passed across @rusackas thanks for merging master in on the 15th, flagging this since your approval predates the conflict. |
|
@SEPURI-SAI-KRISHNA looks like there are fresh conflicts... would you mind tackling those, or would you like a hand? |
|
Thanks @rusackas, on it, no hand needed. Worth flagging what the conflict turned out to be, since it changes what's left of this PR. The conflict is with #43337, which rewrote What remains, and is still entirely unfixed on master, is
So the PR is now scoped to One test note: my |
|
Retitling the PR and updating/amending the description on the PR definitely helps for reviews and for historical record. |
|
retitled and rewrote the description, the summary now covers only the select() fix, with a section recording what #43337 absorbed and how the regression guard was preserved. |
|
Rechecked this against the rebased head rather than trusting the old approval. Root cause still checks out against |
SUMMARY
SqlaTable.exec_queryconverts onlyInvalidPostProcessingErrorinto aQueryObjectValidationError(→ 400). Anything else raised duringpost-processing escapes as an unhandled 500.
select'sexcludeoption didexactly that for malformed
post_processinginput onPOST /api/v1/chart/data.select'sexcludeoption was never validated.validate_column_argsonly inspects argnames that appear in the options, sonaming a non-existent
"drop"meantexcludewas unchecked anddf.drop(exclude, axis=1)raised a rawKeyError:{"operation": "select", "options": {"exclude": ["does_not_exist"]}}→
KeyError: "['does_not_exist'] not found in axis", surfacing as a 500.I ran an AST scan over every
@validate_column_argsusage in the tree; thisis the only decorator/signature mismatch.
Fixing the name alone left two sibling 500s in the same function:
excludeis applied after thecolumnsprojection, socolumns=["y"], exclude=["label"]passes validation against the incomingDataFrame and then
KeyErrors on the narrowed one. That path is now avalidation error naming the offending column.
validate_column_argsnormalises a scalar throughscalar_to_sequencetovalidate, then hands the original value on, so a bare
exclude="label"was iterated character by character. It is normalised before use.
The
excludedocstring claimed post-rename names should be referenced, whichis backwards — it is applied before
rename— so it is corrected.What changed since the first review
This PR originally carried a second, unrelated fix: a malformed i18n
placeholder in
exec_post_processing, whereraised
KeyError: 'operation'fromflask_babelwhile constructingInvalidPostProcessingError, so the intended 400 never surfaced.That fix has since landed on master independently, as part of #43337's
rewrite of
exec_post_processingfor theEXTRA_PANDAS_POSTPROCESSING_OPSextension point. On merging master I took its version of
query_object.pywholesale, so that file no longer appears in this diff.
What is retained is the regression guard. #43337 added
test_exec_post_processing_unknown_op_raises, which asserts the error typebut not the message, so the placeholder could regress unnoticed. Rather than
ship a near-duplicate test, this PR adds the one distinguishing assertion —
that the message names the offending operation — to that existing test.
The PR is therefore now scoped to
select.pyplus tests.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable — API error handling, no UI change.
TESTING INSTRUCTIONS
pytest tests/unit_tests/pandas_postprocessing/test_select.py \ tests/unit_tests/queries/query_object_test.pyAdds
test_select_invalid_excludeandtest_select_exclude_accepts_scalar,plus
test_exec_post_processing_missing_operation.To confirm they are genuine regression tests, revert the source change and
re-run —
select(df, exclude=["abc"])goes back toKeyError: "['abc'] not found in axis".Behaviour after the change — every previously-valid call is unchanged:
exclude=["abc"]InvalidPostProcessingError(wasKeyError)exclude=["label"]["y"]exclude="label"(scalar)["y"](was iterated per character)rename={"y":"y1"}, exclude=["label"]["y1"]columns=["y"], exclude=["label"]InvalidPostProcessingError(wasKeyError)columns=["y","label"], exclude=["label"]["y"]columns=["y","label"]["y", "label"]Wider sweep, no regressions:
ADDITIONAL INFORMATION