fix(ui): sanitize search fields to prevent crash on non-string values #9452
+9
−1
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.
Description
This PR fixes a crash in the application search bar (Issue #9392) where
TypeError: I.trim is not a functionwould occur if a searchable field (likedescription) contained a non-string value (e.g., a number or object) from a malformed import or database state.The Fix
I updated the
isMatchedfunction inuse-filtered-requests.tsto implement a sanitization pipeline:nullorundefinedvalues.String()before passing them to the fuzzy matcher.This ensures that
trim()is never called on a non-string type, preventing the runtime crash.Verification
Reproduction:
I reproduced the crash locally by importing a workspace with a numeric
descriptionfield (12345instead of"12345"). The app previously crashed upon typing in the search bar.Validation:
With this fix applied, searching against the same malformed data works correctly. The numeric values are coerced to strings and matched without error.
Closes #9392