Skip to content

fix(searchQueryBuilder): Add array guard to collapseTextTokens#115719

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-274x-tokens-reduce-array-guard
Draft

fix(searchQueryBuilder): Add array guard to collapseTextTokens#115719
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-274x-tokens-reduce-array-guard

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 18, 2026

This PR addresses JEST-274X, a TypeError: tokens.reduce is not a function occurring in collapseTextTokens within static/app/components/searchQueryBuilder/utils.tsx.

The root cause was identified as parseSearch (specifically after the 804a4be grammar refactor) returning a truthy non-array value for certain aggregate filter queries (e.g., p75(span.duration):>300ms test) when flattenParenGroups is enabled. The collapseTextTokens function previously only guarded against null values for tokens, but not against non-array types.

To fix this, a defensive check if (!Array.isArray(tokens)) { return null; } has been added to collapseTextTokens. This ensures that tokens is always an array before .reduce() is called, preventing the TypeError without altering the core parsing logic.

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 JEST-274X

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.52%

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