eschutho opened a new pull request, #44770:
URL: https://github.com/apache/superset/pull/44770

   ### SUMMARY
   
   `ChartDataRestApi.get_data` (`GET /api/v1/chart/<pk>/data/`) parses 
`chart.params` with `json.loads()` and guards against malformed JSON via a 
`(TypeError, json.JSONDecodeError)` except clause, but does not guard against 
JSON that parses successfully to a non-dict value (e.g. `"foo"`, `[1,2]`, `42`, 
`null`).
   
   The `params` field in `charts/schemas.py` uses 
`validate=utils.validate_json`, which only checks that the string is parseable 
JSON — not that it decodes to an object. So a Chart Create/Update API request 
can persist a non-dict `params` value.
   
   When `form_data` is a non-empty non-dict (string/list/int), it flows through 
`_get_data_response` → `_send_chart_response` → `apply_client_processing`, 
which does `form_data.get("viz_type")` and raises a raw `AttributeError` — 
surfacing as an opaque 500 to the client.
   
   **Fix**: Add an `isinstance(form_data, dict)` guard after the existing 
try/except, mirroring the established pattern in 
`mcp_service/chart/tool/update_chart.py::_get_existing_form_data`.
   
   Follow-up to #44731, which fixed the same bug class on a different call path 
(`Slice.form_data` property in `models/slice.py`).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Not applicable (no UI change).
   
   ### TESTING INSTRUCTIONS
   1. Run the new regression tests:
      ```bash
      pytest tests/unit_tests/charts/data/test_non_dict_params.py -v
      ```
   2. All 7 tests should pass (3 proving the downstream crash exists, 4 proving 
the guard prevents it).
   3. To verify red-before/green-after: stash `superset/charts/data/api.py`, 
re-run the `test_get_data_falls_back_for_non_dict_params` tests (they fail), 
pop the stash (they pass).
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] 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
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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