Skip to content

defensive code when parsing FT.SEARCH results#463

Merged
mgravell merged 5 commits intomasterfrom
marc/search-args-check
Mar 12, 2026
Merged

defensive code when parsing FT.SEARCH results#463
mgravell merged 5 commits intomasterfrom
marc/search-args-check

Conversation

@mgravell
Copy link
Copy Markdown
Collaborator

@mgravell mgravell commented Feb 5, 2026

fix #448

  • do not assume results array is non-empty
  • simplify and verify score/content/payload permutations

The biggest "fix" is the second one; in the existing code, a mismatch in the setup code (that calculates the elements-per-row) and the actual reading code meant that the "with payloads, without content" scenario applied different logic in the two places (nested if in the init, but independent if in the parser), with unpredictable results. This has been simplified.


Note

Medium Risk
Changes core FT.SEARCH response parsing logic; incorrect stride/offset handling could corrupt document parsing for certain WITHSCORES/WITHPAYLOADS/NOCONTENT combinations, though new tests reduce regression risk.

Overview
Hardens FT.SEARCH result parsing in SearchResult by guarding against unexpected empty responses and by replacing the previous offset/step calculation with a single stride + sequential offset reader that stays consistent across WITHSCORES, WITHPAYLOADS, and NOCONTENT permutations.

Expands test coverage to run query-parameter search tests across all 8 combinations of scores/payloads/content, and adds assertions that payloads and returned fields are present/absent as requested.

Written by Cursor Bugbot for commit 42e33a3. This will update automatically on new commits. Configure here.

 - do not assume results array is non-empty
 - simplify and verify score/content/payload permutations
@mgravell mgravell changed the title defensive code in parsing FT.SEARCH results: defensive code when parsing FT.SEARCH results Feb 5, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Mar 12, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@mgravell mgravell merged commit e5cfed9 into master Mar 12, 2026
45 of 46 checks passed
@mgravell mgravell deleted the marc/search-args-check branch March 12, 2026 10:34
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.

Possible bug: SearchCommands.SearchAsync() occasionally throws an IndexOutOfRange exception

1 participant