Skip to content

fix(dashboard): include native filter names in filter_state GET response - #44043

Merged
rusackas merged 3 commits into
masterfrom
fix/issue-36053-suggested-open-pr
Sep 16, 2026
Merged

rusackas merged 3 commits into
masterfrom
fix/issue-36053-suggested-open-pr

Conversation

@rusackas

@rusackas rusackas commented Sep 9, 2026

Copy link
Copy Markdown
Member

SUMMARY

GET /api/v1/dashboard/{pk}/filter_state/{key} only ever returned the raw cached value. That value is a DataMaskStateWithId — a map keyed by filter id — not a flat object, so there's no name/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's native_filter_configuration.

This cross-references the filter ids present in the cached value against the dashboard's native_filter_configuration and returns a names map (filter id -> label) alongside value, 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 new test_get_dashboard_filter_state_includes_names test that seeds a dashboard's native_filter_configuration and a matching cached filter_state entry (shaped like the real DataMaskStateWithId), then asserts the GET response includes the correct names map.
  • pytest tests/unit_tests/dashboards/filter_state_api_test.py

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

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]>
@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #05b678

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/dashboards/filter_state/api.py - 1
    • Redundant dashboard DB fetch · Line 289-289
      `get_filter_names(pk, value)` re-fetches the dashboard via `DashboardDAO.get_by_id_or_slug()`, but `command.run()` already fetched it inside `check_access()`. This doubles DB queries on a hot GET path. Consider returning the dashboard from `check_access` and reusing it in `get_filter_names`. Note `get_by_id_or_slug` can also raise `DashboardNotFoundError`/`DashboardAccessDeniedError`, which this try/except doesn't catch (falls through to `@safe` → 500).
  • superset/commands/dashboard/filter_state/get.py - 1
    • Unhandled DAO exception · Line 66-66
      get_filter_names calls DashboardDAO.get_by_id_or_slug directly, which can raise DashboardNotFoundError/DashboardAccessDeniedError. The API handler only catches TemporaryCacheAccessDeniedError/TemporaryCacheResourceNotFoundError, so a dashboard deleted between get()'s check_access and this call (TOCTOU) would surface as an unhandled 500. Consider importing DashboardNotFoundError and DashboardAccessDeniedError and wrapping the get_by_id_or_slug call in a try/except that returns {} on failure so the method degrades gracefully.
Review Details
  • Files reviewed - 3 · Commit Range: 462eb52..462eb52
    • superset/commands/dashboard/filter_state/get.py
    • superset/dashboards/filter_state/api.py
    • tests/integration_tests/dashboards/filter_state/api_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added api Related to the REST API preset-io labels Sep 9, 2026
@netlify

netlify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 4765229
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aa1d058f2b7f30008f82b80
😎 Deploy Preview https://deploy-preview-44043--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. In superset/commands/dashboard/filter_state/get.py, the native_filter_configuration is retrieved from metadata.get("native_filter_configuration", []). If this key is missing or null in the JSON metadata, metadata.get returns [] (the default), which is safe. However, if the metadata itself is malformed or if the logic expects a list but receives None (depending on how metadata is populated), iterating over it can raise a TypeError.

To resolve this, ensure native_filters is explicitly handled as a list even if the configuration is missing or null:

        native_filters = metadata.get("native_filter_configuration")
        if not isinstance(native_filters, list):
            native_filters = []

This ensures that native_filters is always a list, preventing TypeError during iteration. Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

superset/commands/dashboard/filter_state/get.py

native_filters = metadata.get("native_filter_configuration")
        if not isinstance(native_filters, list):
            native_filters = []

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.78947% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.00%. Comparing base (daf41bd) to head (af3da2f).
⚠️ Report is 86 commits behind head on master.

Files with missing lines Patch % Lines
superset/commands/dashboard/filter_state/get.py 56.52% 7 Missing and 3 partials ⚠️
superset/dashboards/filter_state/api.py 80.00% 2 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
hive 37.34% <21.05%> (-0.28%) ⬇️
mysql 56.89% <65.78%> (-0.50%) ⬇️
postgres 56.91% <65.78%> (-0.51%) ⬇️
presto 39.23% <21.05%> (-0.31%) ⬇️
python 84.48% <65.78%> (+0.14%) ⬆️
sqlite 56.61% <65.78%> (-0.50%) ⬇️
unit 75.78% <21.05%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe
sadpandajoe self-requested a review September 9, 2026 17:38
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]>
@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Sep 9, 2026
…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]>
@bito-code-review

bito-code-review Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #c13ae5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 462eb52..af3da2f
    • superset/commands/dashboard/filter_state/get.py
    • tests/integration_tests/dashboards/filter_state/api_tests.py
  • Files skipped - 1
    • docs/static/resources/openapi.json - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit dd60cc2 into master Sep 16, 2026
75 checks passed
@rusackas
rusackas deleted the fix/issue-36053-suggested-open-pr branch September 16, 2026 00:22
villebro pushed a commit that referenced this pull request Sep 16, 2026
…nse (#44043)

Co-authored-by: Claude Sonnet 5 <[email protected]>
(cherry picked from commit dd60cc2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation preset-io size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /api/v1/dashboard/{pk}/filter_state/{key} does not return "name" property

2 participants