Skip to content

fix(dashboards): Coerce numeric tag values to strings in global filter - #123106

Draft
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix/coerce-numeric-tag-values
Draft

fix(dashboards): Coerce numeric tag values to strings in global filter#123106
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix/coerce-numeric-tag-values

Conversation

@sentry

@sentry sentry Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the issue "Error: Dashboard filter addOption received a non-string value" (JAVASCRIPT-3BHX).

Problem:
The addOption function in filterSelector.tsx was receiving non-string values, leading to an error being captured by Sentry. This occurred because certain tag values returned by the API (e.g., GoSdkVersion integers, user.geo.subregion codes) were numeric, despite being typed as string in TagValueWithCount.value.

Root Cause:
The existing type guard typeof value === 'string' ? value : value.value in the fetchedFilterValues loop failed to properly coerce these numeric values to strings. When value.value was a number, it was passed directly to addOption, which expected a string. The addOption function itself had a Sentry error capture for non-string inputs, but this only logged the issue without preventing the underlying problem.

Solution:

  1. Updated addOption: The addOption function now explicitly coerces rawValue to a string if it's a number or boolean. Other non-string, non-numeric, non-boolean types (like objects) will result in an empty string, preventing [object Object] from appearing.
  2. Fixed fetchedFilterValues loop: The type guard in the fetchedFilterValues.forEach loop now explicitly calls String(value.value ?? '') to ensure numeric values from TagValueWithCount are correctly converted to strings.
  3. Removed Sentry error capture: The Sentry.withScope block and the Sentry import were removed as the values are now correctly handled, making the error capture redundant.
  4. Addressed ESLint warnings: Removed globalFilter.tag.key from the useMemo dependency array as it was no longer needed after removing the Sentry error capture, and refined the rawValue coercion logic to satisfy @typescript-eslint/no-base-to-string.

This ensures that all tag values are consistently handled as strings within the dashboard global filter selector, preventing runtime type errors and improving data consistency.

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

@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 Aug 29, 2026
@sentry sentry Bot changed the title fix(dashboards): Coerce numeric tag values to strings in filter selector fix(dashboards): Coerce numeric tag values to strings in global filter Aug 29, 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