Skip to content

Conversation

@DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Dec 5, 2025

  1. Add ability to disable removeFilter option, this is currently done when the dashboard is prebuilt, and a filter exists in it's prebuilt config.
  2. remove the temporaryFilters query param and add isTemporary property to GlobalFilters which is easier to manage then having two separate query params
  3. Add tests cases to dashboard link field renderer and filter bar

@DominikB2014 DominikB2014 requested a review from a team as a code owner December 5, 2025 21:44
@linear
Copy link

linear bot commented Dec 5, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 5, 2025
Copy link
Member

@Ahmed-Labs Ahmed-Labs left a comment

Choose a reason for hiding this comment

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

I tested global filters in non-prebuilt dashboards and it seems that unsaved changes don't get picked up (changes get pushed to url params but no save button pops up)

@DominikB2014
Copy link
Contributor Author

I tested global filters in non-prebuilt dashboards and it seems that unsaved changes don't get picked up (changes get pushed to url params but no save button pops up)

👍 Thanks for testing! We should probs add some test cases here to prevent regressions

@DominikB2014 DominikB2014 requested a review from a team as a code owner December 8, 2025 16:56
Comment on lines +73 to +75
const prebuiltDashboardFilters: GlobalFilter[] = prebuiltDashboardId
? (PREBUILT_DASHBOARDS[prebuiltDashboardId].filters.globalFilter ?? [])
: [];
Copy link

Choose a reason for hiding this comment

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

Bug: Missing validation for prebuiltDashboardId as a key in PREBUILT_DASHBOARDS can lead to runtime crash when accessing .filters.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The code at static/app/views/dashboards/filtersBar.tsx:73-75 accesses PREBUILT_DASHBOARDS[prebuiltDashboardId] without validating if prebuiltDashboardId is a valid key within PREBUILT_DASHBOARDS. This can lead to PREBUILT_DASHBOARDS[prebuiltDashboardId] evaluating to undefined if prebuiltDashboardId exists but is not a recognized key. Subsequently, attempting to access .filters on undefined will cause a runtime crash. This can occur due to incomplete deployments, API mismatches, or server/client version discrepancies.

💡 Suggested Fix

Before accessing PREBUILT_DASHBOARDS[prebuiltDashboardId], add a check to ensure prebuiltDashboardId in PREBUILT_DASHBOARDS to prevent accessing properties on undefined.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/dashboards/filtersBar.tsx#L73-L75

Potential issue: The code at `static/app/views/dashboards/filtersBar.tsx:73-75` accesses
`PREBUILT_DASHBOARDS[prebuiltDashboardId]` without validating if `prebuiltDashboardId`
is a valid key within `PREBUILT_DASHBOARDS`. This can lead to
`PREBUILT_DASHBOARDS[prebuiltDashboardId]` evaluating to `undefined` if
`prebuiltDashboardId` exists but is not a recognized key. Subsequently, attempting to
access `.filters` on `undefined` will cause a runtime crash. This can occur due to
incomplete deployments, API mismatches, or server/client version discrepancies.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 6235892

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typing wouldn't allow this

Copy link
Member

@Ahmed-Labs Ahmed-Labs left a comment

Choose a reason for hiding this comment

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

Lgtm!

@DominikB2014 DominikB2014 merged commit bd1a27a into master Dec 8, 2025
48 checks passed
@DominikB2014 DominikB2014 deleted the dominikbuszowiecki/browse-177-global-filter-change-on-query-details-page-has-no-effect-on branch December 8, 2025 18:31
ryan953 pushed a commit that referenced this pull request Dec 9, 2025
1. Add ability to disable removeFilter option, this is currently done
when the dashboard is prebuilt, and a filter exists in it's prebuilt
config.
2. remove the `temporaryFilters` query param and add `isTemporary`
property to `GlobalFilters` which is easier to manage then having two
separate query params
3. Add tests cases to dashboard link field renderer and filter bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants