Repository navigation
fix(dashboard): include native filter names in filter_state GET response - #44043
Conversation
The cached filter_state value is a DataMaskStateWithId keyed by filter id, not a flat object, so a client can't reliably read a "name"/label out of it. Cross-reference the filter ids present in the cached value against the dashboard's native_filter_configuration and return a `names` map (filter id -> label) alongside `value`. Fixes #36053 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Code Review Agent Run #05b678Actionable Suggestions - 0Additional Suggestions - 2
Review 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 |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The flagged issue is correct. In To resolve this, ensure native_filters = metadata.get("native_filter_configuration")
if not isinstance(native_filters, list):
native_filters = []This ensures that superset/commands/dashboard/filter_state/get.py |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44043 +/- ##
==========================================
+ Coverage 79.89% 80.00% +0.10%
==========================================
Files 2916 2918 +2
Lines 170755 171857 +1102
Branches 39569 39811 +242
==========================================
+ Hits 136432 137491 +1059
+ Misses 31805 31777 -28
- Partials 2518 2589 +71
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:
|
The GET /dashboard/{pk}/filter_state/{key} docstring gained a `names`
response property but docs/static/resources/openapi.json wasn't
regenerated, tripping the check-openapi-spec-drift CI check.
Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…e names
get_filter_names() called .get("native_filter_configuration", []), which
only falls back when the key is missing. Dashboards with an explicit
`"native_filter_configuration": null` in json_metadata raised a TypeError
when iterating, turning the GET into a 500. Normalize with `or []` instead
and add a regression test for the null case.
Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Code Review Agent Run #c13ae5Actionable 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 |
…nse (#44043) Co-authored-by: Claude Sonnet 5 <[email protected]> (cherry picked from commit dd60cc2)
SUMMARY
GET /api/v1/dashboard/{pk}/filter_state/{key}only ever returned the raw cachedvalue. That value is aDataMaskStateWithId— a map keyed by filter id — not a flat object, so there's noname/label a client can read out of it directly (#36053). As discussed on the issue and on the prior attempt (#36262), the filter's human-readable label isn't part of the cached blob at all; it lives in the dashboard'snative_filter_configuration.This cross-references the filter ids present in the cached
valueagainst the dashboard'snative_filter_configurationand returns anamesmap (filter id -> label) alongsidevalue, so a client can look up each filter's label without needing to separately fetch and parse the dashboard's filter configuration.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - API response change only.
Before:
{"value": "{\"NATIVE_FILTER-abc\":{\"id\":\"NATIVE_FILTER-abc\",\"extraFormData\":{}}}"}After:
{ "value": "{\"NATIVE_FILTER-abc\":{\"id\":\"NATIVE_FILTER-abc\",\"extraFormData\":{}}}", "names": {"NATIVE_FILTER-abc": "My Filter Label"} }TESTING INSTRUCTIONS
pytest tests/integration_tests/dashboards/filter_state/api_tests.py— includes a newtest_get_dashboard_filter_state_includes_namestest that seeds a dashboard'snative_filter_configurationand a matching cached filter_state entry (shaped like the realDataMaskStateWithId), then asserts the GET response includes the correctnamesmap.pytest tests/unit_tests/dashboards/filter_state_api_test.pyADDITIONAL INFORMATION
🤖 Generated with Claude Code