Skip to content

fix: don't push empty originalQuery onto badQueries (supersedes #845)#872

Merged
tkirda merged 1 commit into
masterfrom
fix/empty-query-poisons-badqueries
May 21, 2026
Merged

fix: don't push empty originalQuery onto badQueries (supersedes #845)#872
tkirda merged 1 commit into
masterfrom
fix/empty-query-poisons-badqueries

Conversation

@tkirda
Copy link
Copy Markdown
Member

@tkirda tkirda commented May 21, 2026

Closes #845.

Summary

isBadQuery matches by prefix (q.indexOf(bad) === 0). Any empty string in badQueries matches every subsequent query — so a single empty-query response silently blocks all ajax requests forever. Reachable with minChars: 0 plus a server response containing no suggestions.

Guard the push so an empty originalQuery never enters the list:

if (options.preventBadQueries && !result.suggestions.length && originalQuery) {
    this.badQueries.push(originalQuery);
}

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

  • New spec Autocomplete Async — empty originalQuery > does not push an empty originalQuery onto badQueries — fails on master (badQueries = [""] and the second non-empty ajax request is short-circuited), passes with the fix.
  • Existing preventBadQueries spec still green — fix only narrows the push condition.
  • Full suite green locally (npm test — 40 / 40).
  • npm run lint && npm run format:check && npm run typecheck && npm run build all green.

🤖 Generated with Claude Code

`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>
@tkirda tkirda merged commit e9cc1b7 into master May 21, 2026
1 check passed
@tkirda tkirda deleted the fix/empty-query-poisons-badqueries branch May 21, 2026 15:25
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.

2 participants