SEPURI-SAI-KRISHNA opened a new pull request, #45423:
URL: https://github.com/apache/superset/pull/45423
### SUMMARY
Fixes #45422.
A `contribution` post-processing operation with no `options` key made
`/api/v1/chart/data` return 500. `options` is optional in
`ChartDataPostProcessingOperationSchema`, so `{"operation": "contribution"}`
is
valid input, but `ensure_totals_available` wrote into `pp["options"]` with a
bare subscript, raising `KeyError: 'options'`, which is not in the chart-data
handler list and surfaced as a 500.
The fix uses `pp.setdefault("options", {})`, treating `options` the way the
schema already does. The result is identical to sending `"options": {}`.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Request with two query objects, the first carrying
`post_processing: [{"operation": "contribution"}]` (no options) and the
second a
bare totals query (`metrics` only):
Before: `500` with `KeyError: 'options'`.
After: `200`; the operation receives `options = {"contribution_totals":
{...}}`.
### TESTING INSTRUCTIONS
```
pytest tests/unit_tests/common/test_query_context_processor.py -k
contribution_without_options
```
New `test_ensure_totals_available_contribution_without_options` calls the
real
`ensure_totals_available` with an optionless contribution query; it raises
`KeyError` without the fix and passes with it, ending with
`contribution_totals` present under a created `options` dict.
### ADDITIONAL INFORMATION
- [x] Has associated issue: #45422
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]