fix: don't push empty originalQuery onto badQueries (supersedes #845)#872
Merged
Conversation
`isBadQuery` matches by prefix: `q.indexOf(bad) === 0`. An empty entry in `badQueries` matches every subsequent query, silently blocking all ajax requests after the first empty-query response. Reachable with `minChars: 0` plus an empty server response. Guard the push so an empty `originalQuery` never enters the list. Ports szabto's #845 fix forward to the 2.x TypeScript source. Closes #845. Co-Authored-By: szabto <szabotamas93@gmail.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Closes #845.
Summary
isBadQuerymatches by prefix (q.indexOf(bad) === 0). Any empty string inbadQueriesmatches every subsequent query — so a single empty-query response silently blocks all ajax requests forever. Reachable withminChars: 0plus a server response containing no suggestions.Guard the push so an empty
originalQuerynever enters the list:Ports @szabto's #845 fix forward from the pre-2.0 JavaScript source to the 2.x TypeScript source. Credit goes to szabto via
Co-Authored-By:on the commit.Test plan
Autocomplete Async — empty originalQuery > does not push an empty originalQuery onto badQueries— fails onmaster(badQueries = [""]and the second non-empty ajax request is short-circuited), passes with the fix.preventBadQueriesspec still green — fix only narrows the push condition.npm test— 40 / 40).npm run lint && npm run format:check && npm run typecheck && npm run buildall green.🤖 Generated with Claude Code