Skip to content

fix(discover): Prevent TypeError when decoding null fields from URL - #121035

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/discover-null-field-match-error
Draft

fix(discover): Prevent TypeError when decoding null fields from URL#121035
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/discover-null-field-match-error

Conversation

@sentry

@sentry sentry Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of null (reading 'match') that occurred when malformed URL query parameters for fields were present, specifically when an empty field parameter was included (e.g., &field=title&field).

Root Cause:
decodeFields in static/app/utils/discover/eventView.tsx uses decodeList to parse URL query parameters. When a query string like &field=title&field is encountered, decodeList can return an array containing null elements (e.g., ['title', null]). decodeFields then processed these null elements without validation, passing them downstream. Eventually, these null values reached functions like parseFunction in static/app/utils/discover/fields.tsx, which expected a string and attempted to call .match() on null, leading to the TypeError.

Solution:
An if (!field) return; guard has been added within the forEach loop in decodeFields. This ensures that any null or falsy field entries returned by decodeList are filtered out before being added to the parsed array. This prevents null values from propagating to downstream functions that expect string inputs, thereby resolving the TypeError.

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-3AQT

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 1, 2026
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