Problem
Bounded CLI find output can emit a human-only cursor validation error despite an explicit --json selector. Machine consumers receive empty stdout and must parse stderr to recover the category and hint.
This was found during #5399 validation, but it also reproduces with the existing line-local regex mode and is outside that feature's implementation scope.
Reproduction
From an indexed checkout, using the repository-built Debug net8.0 binary:
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll find using --regex \
--path src/CodeIndex/Cli/QueryCommandRunner.Find.cs --json --fields path \
--cursor bad --db .cdidx/codeindex.db > /tmp/cursor.stdout 2> /tmp/cursor.stderr
Actual: exit 1, empty stdout, stderr:
Error [E010_USAGE_ERROR]: cursor_malformed: --cursor must be an opaque response:v2 cursor returned as next_cursor.
Hint: Use the command help to pass positive --limit/--max-json-bytes values and a next_cursor returned by the same query.
Changing a result-affecting flag while replaying a valid bounded find cursor likewise produces a human cursor-mismatch diagnostic. Observed on macOS arm64 with .NET 8, version 1.50.3, while developing from origin/main 3606a5eaa533a27bfbddc606b0fb41dcd9d075cb.
Expected
Explicit machine output should return a versioned structured error on stdout with exit 1, command/error identity, the cursor reason and recovery guidance, without human-only stderr. Preserve existing human-mode diagnostics and handle an insufficient output byte budget truthfully.
Start with the bounded response validation/error paths in src/CodeIndex/Cli/JsonEnvelopeWrapper.Bounded.cs. Cover malformed, query-mismatched and stale cursors with the supported JSON/envelope/field selectors; retain ordinary human and count-cursor behavior.
Open-issue duplicate searches for cursor JSON, cursor stderr, pagination JSON and structured errors found no matching issue other than #5399.
Problem
Bounded CLI find output can emit a human-only cursor validation error despite an explicit
--jsonselector. Machine consumers receive empty stdout and must parse stderr to recover the category and hint.This was found during #5399 validation, but it also reproduces with the existing line-local regex mode and is outside that feature's implementation scope.
Reproduction
From an indexed checkout, using the repository-built Debug net8.0 binary:
Actual: exit 1, empty stdout, stderr:
Changing a result-affecting flag while replaying a valid bounded find cursor likewise produces a human cursor-mismatch diagnostic. Observed on macOS arm64 with .NET 8, version 1.50.3, while developing from origin/main
3606a5eaa533a27bfbddc606b0fb41dcd9d075cb.Expected
Explicit machine output should return a versioned structured error on stdout with exit 1, command/error identity, the cursor reason and recovery guidance, without human-only stderr. Preserve existing human-mode diagnostics and handle an insufficient output byte budget truthfully.
Start with the bounded response validation/error paths in
src/CodeIndex/Cli/JsonEnvelopeWrapper.Bounded.cs. Cover malformed, query-mismatched and stale cursors with the supported JSON/envelope/field selectors; retain ordinary human and count-cursor behavior.Open-issue duplicate searches for
cursor JSON,cursor stderr,pagination JSONandstructured errorsfound no matching issue other than #5399.