Skip to content

fix: add null guard in getYahooIndiaSuggestions to prevent TypeError#723

Open
Cocoon-Break (kuishou68) wants to merge 1 commit intobrowseros-ai:devfrom
kuishou68:fix/issue-722-yahoo-suggestions-null-check
Open

fix: add null guard in getYahooIndiaSuggestions to prevent TypeError#723
Cocoon-Break (kuishou68) wants to merge 1 commit intobrowseros-ai:devfrom
kuishou68:fix/issue-722-yahoo-suggestions-null-check

Conversation

@kuishou68
Copy link
Copy Markdown

Closes #722

Problem

In getSearchSuggestions.ts, the getYahooIndiaSuggestions function accesses data.gossip.results without any null/undefined guard:

return data.gossip.results.map((item: YahooSuggestionItem) => item.key) || []

If the Yahoo API returns an unexpected response shape (e.g. data.gossip is null or undefined), this throws an uncaught TypeError that can break the search suggestions UI entirely. Every other provider safely uses data[1] || [], but Yahoo lacks this protection.

Fix

Use optional chaining and nullish coalescing, consistent with how other providers handle missing data:

return data?.gossip?.results?.map((item: YahooSuggestionItem) => item.key) ?? []

This ensures an empty array is safely returned when the API response is missing or malformed.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

PR author is not in the allowed authors list.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

@kuishou68
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Missing null check in getYahooIndiaSuggestions causes uncaught TypeError

1 participant