Skip to content

fix(discover): Prevent homepage crash on unmapped dataset param - #123707

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/discover-homepage-dataset-fallback
Draft

fix(discover): Prevent homepage crash on unmapped dataset param#123707
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/discover-homepage-dataset-fallback

Conversation

@sentry

@sentry sentry Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes a TypeError: Cannot read properties of undefined (reading 'environment') that occurred on /explore/discover/homepage/.

Root Cause:
When hasDatasetSelector is enabled and no saved homepage query exists, checkEventView in static/app/views/discover/results.tsx attempts to get a default event view using DEFAULT_EVENT_VIEW_MAP[value]. If the value (derived from the URL's ?dataset= parameter) does not correspond to one of the few keys in DEFAULT_EVENT_VIEW_MAP (e.g., DISCOVER, ERRORS, TRANSACTIONS), the lookup returns undefined. This undefined then propagates through getSavedQueryWithDataset(undefined) and is passed as the newQuery argument to EventView.fromNewQueryWithLocation, causing a crash when newQuery.environment is accessed.

Fix:
Added a nullish coalescing operator (?? DEFAULT_EVENT_VIEW) to the DEFAULT_EVENT_VIEW_MAP[value] lookup in static/app/views/discover/results.tsx. This ensures that if an unrecognized dataset value is encountered, it gracefully falls back to DEFAULT_EVENT_VIEW, guaranteeing a valid NewQuery object is always passed to EventView.fromNewQueryWithLocation.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes JAVASCRIPT-38Z6

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

Metric Before After Delta
Coverage 95.43% 95.43% ±0%
Typed 138,616 138,616 ±0
Untyped 6,640 6,640 ±0
🔍 1 new type safety issue introduced

Type assertions (as) (1 new)

File Line Detail
static/app/views/discover/results.tsx 445 as NewQuerygetSavedQueryWithDataset( DEFAULT_EVENT_VIEW_MAP[value] ?? DEFAULT_EVENT_VIEW )…

This is informational only and does not block the PR.

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.

0 participants