Skip to content

fix: coerce non-string suggestion values at the response boundary#871

Merged
tkirda merged 1 commit into
masterfrom
fix/coerce-non-string-suggestion-values
May 20, 2026
Merged

fix: coerce non-string suggestion values at the response boundary#871
tkirda merged 1 commit into
masterfrom
fix/coerce-non-string-suggestion-values

Conversation

@tkirda
Copy link
Copy Markdown
Member

@tkirda tkirda commented May 20, 2026

Closes #844.

Summary

If a server or local lookup supplies a suggestion with a non-string value (e.g. numeric IDs), downstream string methods such as toLowerCase, replace, substr, and indexOf throw mid-render.

  • verifySuggestionsFormat now coerces any non-string value to a string via String(...), preserving the rest of the suggestion shape via shallow copy.
  • The coercion is also applied to the function-lookup callback path and ahead of the ajax onSearchComplete fire, so all callbacks see a normalized Suggestion.value: string — matching the declared TypeScript contract.

Test plan

  • New describe Autocomplete non-string suggestion values with two specs (local lookup + function callback) — both fail on master with TypeError: ... is not a function, both pass with the fix.
  • Full suite green locally (npm test — 36 / 36).
  • npm run lint && npm run format:check && npm run typecheck && npm run build all green.

🤖 Generated with Claude Code

If a server or local lookup supplies a suggestion with a non-string
`value` (e.g. numeric IDs), downstream string methods such as
`toLowerCase`, `replace`, `substr`, and `indexOf` throw mid-render.

`verifySuggestionsFormat` now coerces any non-string `value` to a
string via `String(...)` (preserving the rest of the suggestion shape
via shallow copy). The coercion is also applied to the function-lookup
callback path and ahead of the ajax `onSearchComplete` fire so all
callbacks see a normalized `Suggestion.value: string`, matching the
declared TypeScript contract.

Closes #844.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tkirda tkirda merged commit 02f58a1 into master May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants