Skip to content

fix(slack): Apply dashboard-stored filters when unfurling widget URLs#113711

Merged
DominikB2014 merged 2 commits intomasterfrom
dominikbuszowiecki/dain-1574-empty-charts-when-unfurling-dashboard-widget-urls
Apr 22, 2026
Merged

fix(slack): Apply dashboard-stored filters when unfurling widget URLs#113711
DominikB2014 merged 2 commits intomasterfrom
dominikbuszowiecki/dain-1574-empty-charts-when-unfurling-dashboard-widget-urls

Conversation

@DominikB2014
Copy link
Copy Markdown
Contributor

Pasting a dashboard widget URL into Slack produced a blank chart when the URL had no query params. The unfurl handler read project, environment, and the date range exclusively from URL params, so a bare /dashboard/{id}/widget/{index}/ link sent an events-timeseries request with no project filter and returned no data.

The dashboard UI itself resolves those filters from Dashboard.projects / Dashboard.filters (and its own DEFAULT_STATS_PERIOD='24h') when the URL doesn't carry them. This change mirrors that precedence server-side:

  1. URL query params (as before)
  2. Dashboard-saved filters via Dashboard.get_filters() — projects, environment, period, start/end, utc, and the all_projects sentinel
  3. Hardcoded FE defaults — DEFAULT_PERIOD bumped from 14d to 24h to match static/app/views/dashboards/data.tsx; project falls back to ALL_ACCESS_PROJECT_ID (-1) so unconfigured dashboards still render data instead of an empty chart

Date range is treated as a unit: if the URL carries any of statsPeriod/start/end, the dashboard-saved range is ignored (no mixing URL statsPeriod with a saved start/end).

localStorage-pinned PageFilters are deliberately not replicated — they aren't reachable from a webhook context, and dashboards pass disablePersistence={true} anyway.

Also adds select_related("dashboard") to _get_widget so accessing widget.dashboard.get_filters() doesn't trigger an extra lazy query.

Refs DAIN-1574

The dashboards unfurl handler read project, environment, and date
range only from URL query params, and many dashboard widget URLs pasted
into Slack carry no query params at all. That produced blank charts:
no project filter meant the events-timeseries call returned no data.

Resolve page filters with URL > dashboard-saved (Dashboard.get_filters)
> FE defaults, matching what the dashboard page shows when opened
directly. When no project is configured anywhere, fall back to
ALL_ACCESS_PROJECT_ID so unfurls still render data instead of an empty
chart. Also bump DEFAULT_PERIOD from 14d to 24h to match the
dashboards-specific DEFAULT_STATS_PERIOD in dashboards/data.tsx.

localStorage-pinned filters are intentionally not replicated; they
aren't reachable from a webhook context.

Refs DAIN-1574
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 22, 2026

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 22, 2026
@DominikB2014 DominikB2014 requested a review from a team April 22, 2026 18:24
@DominikB2014 DominikB2014 marked this pull request as ready for review April 22, 2026 18:24
@DominikB2014 DominikB2014 requested review from a team as code owners April 22, 2026 18:24
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 634fb4b. Configure here.

Comment thread src/sentry/integrations/slack/unfurl/dashboards.py Outdated
The events-timeseries endpoint doesn't consume a utc param, so
forwarding it from URL or dashboard-saved filters was dead code. On
top of that, unfurled charts are viewed across mixed-timezone Slack
audiences, where a single viewer's utc preference isn't meaningful.

Drop it from both paths and update the dashboard start/end test to
assert utc is absent.
@DominikB2014 DominikB2014 merged commit 679026e into master Apr 22, 2026
56 checks passed
@DominikB2014 DominikB2014 deleted the dominikbuszowiecki/dain-1574-empty-charts-when-unfurling-dashboard-widget-urls branch April 22, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants