Skip to content

fix(reports): keep native filters with quoted values in report permalinks - #46060

Merged
eschutho merged 2 commits into
masterfrom
fix-report-native-filters-quote-encoding
Nov 12, 2026
Merged

eschutho merged 2 commits into
masterfrom
fix-report-native-filters-quote-encoding

Conversation

@eschutho

@eschutho eschutho commented Nov 7, 2026

Copy link
Copy Markdown
Member

SUMMARY

Dashboard reports and alerts with native filters (ALERT_REPORTS_FILTER) sent unfiltered data, without any error, whenever a selected filter value needed rison quoting (text with a space, comma or quote) or whenever a numeric-range or time-range filter was used. A single such filter caused all of the report's filters to be dropped, and the run was still recorded as a success.

Root cause: ReportSchedule.get_native_filters_params replaced ' with %27 in the rison string. That string is stored in the dashboard permalink state (urlParams), and Superset.dashboard_permalink URL-encodes every urlParams value when it redirects, so %27 became %2527. The frontend decodes the parameter once, rison.decode then fails on the literal %27, and no native filter is preselected. Rison only emits quotes for values that need them (spaces, commas, quotes; range labels and time ranges always contain spaces), which is why single-word values worked.

Fix:

  • Remove the %27 replacement so the raw rison string is URL-encoded exactly once by the redirect. The redirect's per-value urlencode (which guards against parameter injection) is unchanged.
  • Add a small check in get_native_filters_params that the generated value survives urlencode -> one decode -> rison.loads. If it does not, an execution warning naming the filter ids that were not applied is recorded instead of failing silently.

TESTING INSTRUCTIONS

Unit tests (all run in CI):

pytest tests/unit_tests/reports/model_test.py \
       tests/unit_tests/commands/report/execute_test.py \
       tests/unit_tests/views/test_dashboard_permalink_native_filters.py
  • model_test.py: the test that pinned the old %27 behaviour is replaced by parametrized round-trip cases (single word, multi-word, comma, single quote, !, non-ASCII, numeric range, relative and absolute time range, and a combination), plus a single-word-unchanged test and a warning test.
  • execute_test.py: get_dashboard_urls produces round-trippable permalink urlParams with ALERT_REPORT_TABS on and off.
  • test_dashboard_permalink_native_filters.py (new): sends the same cases through the real dashboard_permalink redirect and decodes the resulting URL.

Manual: create a dashboard report with a native filter on a multi-word value (for example North America), a numeric range and a time range; run it and confirm the attachment and the dashboard permalink show the filters applied.

Test limitations: there is no DB-backed ReportScheduleDAO integration test, and the browser-side decode is covered by simulating URLSearchParams decoding in Python rather than in a real browser.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: ALERT_REPORTS_FILTER (and ALERT_REPORT_TABS for per-tab reports)
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

get_native_filters_params replaced "'" with "%27" in the rison string. The
dashboard permalink redirect URL-encodes every urlParam value, so the
literal "%27" became "%2527" and the frontend could not rison-decode the
native_filters param. Any filter value needing rison quoting (spaces,
commas, quotes) and every numeric-range or time-range filter caused all
of the report's filters to be dropped, while the run still reported
Success.

Return raw rison and let the redirect encode it exactly once. Also verify
the encoded value round-trips and surface a warning naming the filters
that would not be applied if it does not.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.22%. Comparing base (3f7412c) to head (6773691).
⚠️ Report is 39 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46060      +/-   ##
==========================================
+ Coverage   85.17%   85.22%   +0.04%     
==========================================
  Files        3082     3083       +1     
  Lines      210472   211268     +796     
  Branches    49610    49786     +176     
==========================================
+ Hits       179273   180047     +774     
- Misses      27809    27820      +11     
- Partials     3390     3401      +11     
Flag Coverage Δ
hive 34.05% <0.00%> (-0.08%) ⬇️
mysql 51.81% <100.00%> (-0.08%) ⬇️
postgres 51.83% <100.00%> (-0.07%) ⬇️
presto 35.69% <0.00%> (-0.09%) ⬇️
python 88.11% <100.00%> (+0.06%) ⬆️
sqlite 51.52% <100.00%> (-0.12%) ⬇️
unit 83.24% <100.00%> (+0.14%) ⬆️

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 marked this pull request as ready for review November 11, 2026 16:32
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 67736912e9ca

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down, @eschutho! With the %27 gone the redirect value is decoded exactly once, and the frontend's rison reads every filter shape back correctly. LGTM, with one non-blocking note inline.

Comment thread superset/reports/models.py Outdated
query = parse.urlencode([("native_filters", encoded)])
try:
decoded = parse.parse_qs(query)["native_filters"][0]
return rison.loads(decoded) == params

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker. This decodes with Python rison, which is stricter than the frontend's: a value with a newline (e.g. "a\nb") gets written unquoted as !(a\nb), the Python loads rejects it, and we warn "not applied" even though the dashboard decodes and applies it fine. Of the shapes I tried, that was the only one that tripped this check. Is it worth keeping, or should we drop it now that the encoding itself is right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and good catch. A newline value was the only shape that false-warned: Python rison.dumps emits it unquoted, Python rison.loads rejects it, while the frontend decodes it fine. A tab or CR value did not trip the check.

Since the encoding is correct by construction now and a Python decode can't stand in for the frontend decoder, I dropped the round-trip check and its warning in 6773691. I replaced the mock-only warning test with one that pins the newline case (it failed before the change) and kept the browser round-trip tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. The PR merged before we got to it, so we're leaving the check as is for now. The false "not applied" warning only shows up for values containing a newline, and the encoding fix itself is correct. If it turns out to be noisy we can drop the Python decode check in a small follow-up.

The check decoded the rison with Python rison, which is stricter than the
frontend decoder: a value containing a newline is emitted unquoted, Python
rejects it, and a "not applied" warning was raised although the dashboard
decodes and applies the filter. The encoding is already correct by
construction, so remove the check and pin the newline case with a test.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@netlify

netlify Bot commented Nov 11, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 6773691
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6af4e9bad2124ed29f1d02d7
😎 Deploy Preview https://deploy-preview-46060--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.

@eschutho
eschutho merged commit 005534b into master Nov 12, 2026
72 of 74 checks passed
@eschutho
eschutho deleted the fix-report-native-filters-quote-encoding branch November 12, 2026 01:16
DamianPendrak added a commit to DamianPendrak/superset that referenced this pull request Nov 13, 2026
Master apache#46060 stopped quoting a report's own native_filters, so the
dashboard page decodes them and renders them in place of the
permalink's stored dataMask. The report pre-check already models the
page that way, so it now checks the values the page renders: the
report's own stored values and the dashboard defaults. Update the
expectations that assumed the page could not decode them, add cases
where an own stored value outside the limits is still refused, drop
the "!%27" text no encoder produces any more, and correct the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
hainenber pushed a commit that referenced this pull request Nov 14, 2026
DamianPendrak added a commit to DamianPendrak/superset that referenced this pull request Nov 14, 2026
…window and apache#46060

The column values API now passes time_window to values_for_column. The
report tests follow master apache#46060: a report's own stored filters decode
and replace the permalink's dataMask, and filters this check can't
decode fail closed. report_payload no longer shares STORED_LAST_YEAR
with the request, so a test that edits its payload can't change the
stored value of the tests after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
villebro pushed a commit that referenced this pull request Nov 14, 2026
…inks (#46060)

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: sadpandajoe <[email protected]>
(cherry picked from commit 005534b)
villebro added a commit that referenced this pull request Nov 14, 2026
The quoted native-filter round-trip test patched
BaseReportState._raise_for_executor_dashboard_access, which comes from
master's #45698 and doesn't exist on 7.0, where get_dashboard_urls doesn't
call it.
nikhilk219 pushed a commit to nikhilk219/superset that referenced this pull request Nov 16, 2026
@github-actions github-actions Bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.20.2 First shipped in 0.20.2 labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io review:draft size/L 🚢 0.20.2 First shipped in 0.20.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants