Repository navigation
fix(reports): keep native filters with quoted values in report permalinks - #46060
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
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:
|
gabotorresruiz
left a comment
There was a problem hiding this comment.
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.
| query = parse.urlencode([("native_filters", encoded)]) | ||
| try: | ||
| decoded = parse.parse_qs(query)["native_filters"][0] | ||
| return rison.loads(decoded) == params |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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]>
…inks (#46060) Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: sadpandajoe <[email protected]>
…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]>
…inks (#46060) Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: sadpandajoe <[email protected]> (cherry picked from commit 005534b)
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.
…inks (apache#46060) Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: sadpandajoe <[email protected]>
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_paramsreplaced'with%27in the rison string. That string is stored in the dashboard permalink state (urlParams), andSuperset.dashboard_permalinkURL-encodes everyurlParamsvalue when it redirects, so%27became%2527. The frontend decodes the parameter once,rison.decodethen 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:
%27replacement so the raw rison string is URL-encoded exactly once by the redirect. The redirect's per-valueurlencode(which guards against parameter injection) is unchanged.get_native_filters_paramsthat the generated value survivesurlencode-> 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):
model_test.py: the test that pinned the old%27behaviour 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_urlsproduces round-trippable permalinkurlParamswithALERT_REPORT_TABSon and off.test_dashboard_permalink_native_filters.py(new): sends the same cases through the realdashboard_permalinkredirect 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
ReportScheduleDAOintegration test, and the browser-side decode is covered by simulatingURLSearchParamsdecoding in Python rather than in a real browser.ADDITIONAL INFORMATION
ALERT_REPORTS_FILTER(andALERT_REPORT_TABSfor per-tab reports)🤖 Generated with Claude Code