fix(dashboards): Coerce numeric tag values to strings in global filter - #123106
Draft
sentry[bot] wants to merge 2 commits into
Draft
fix(dashboards): Coerce numeric tag values to strings in global filter#123106sentry[bot] wants to merge 2 commits into
sentry[bot] wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the issue "Error: Dashboard filter addOption received a non-string value" (JAVASCRIPT-3BHX).
Problem:
The
addOptionfunction infilterSelector.tsxwas receiving non-string values, leading to an error being captured by Sentry. This occurred because certain tag values returned by the API (e.g.,GoSdkVersionintegers,user.geo.subregioncodes) were numeric, despite being typed asstringinTagValueWithCount.value.Root Cause:
The existing type guard
typeof value === 'string' ? value : value.valuein thefetchedFilterValuesloop failed to properly coerce these numeric values to strings. Whenvalue.valuewas a number, it was passed directly toaddOption, which expected a string. TheaddOptionfunction itself had a Sentry error capture for non-string inputs, but this only logged the issue without preventing the underlying problem.Solution:
addOption: TheaddOptionfunction now explicitly coercesrawValueto a string if it's anumberorboolean. Other non-string, non-numeric, non-boolean types (like objects) will result in an empty string, preventing[object Object]from appearing.fetchedFilterValuesloop: The type guard in thefetchedFilterValues.forEachloop now explicitly callsString(value.value ?? '')to ensure numeric values fromTagValueWithCountare correctly converted to strings.Sentry.withScopeblock and theSentryimport were removed as the values are now correctly handled, making the error capture redundant.globalFilter.tag.keyfrom theuseMemodependency array as it was no longer needed after removing the Sentry error capture, and refined therawValuecoercion 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 runThis PR was automatically generated by Sentry. You can adjust this setting at any time.