Repository navigation
fix(cli): propagate paginated response read errors - #3983
Merged
Merged
Conversation
dvd233
marked this pull request as ready for review
October 6, 2026 05:48
11 of 17 tasks
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.
Description
api --paginatediscards errors fromio.ReadAll. An interrupted first response can therefore exit successfully with truncated output. A later interruption can be reported as invalid input, and complete-looking JSON can be accepted despite a failed transfer.The four-line production fix checks the read error after closing each response body and returns the existing
network.errorwrapper used by the single-request path. It preserves the underlying cause, keeps stdout empty on failure, and stops fetching pages. Onlycli/cmd/api/api.goand its test file change.The tests add 14 subcases covering real HTTP truncation, bytes returned together with a read error, first/later pages, non-paginated fallback, HTTP error precedence, JSON/text modes, request counts, and immediate exactly-once body closure.
Type of Change
Testing
Validated locally on Linux/amd64 with Go 1.26.8, from the independent
cli/module:go test ./cmd/api -run TestAPI_Paginate -count=20go test ./cmd/api -race -count=1go test -count=1 ./...go test ./... -race -count=1go vet ./...go build ./...golangci-lint run --new-from-rev=origin/main ./...(v2.14.0, zero issues)scripts/check-skill-wire-vocab.shscripts/check-secret-tokens.shgo mod verify, gofmt inspection, andgit diff --checkAll pass. The identical new tests fail in all 14 subcases on baseline
bccb4b151bae403508da77fbb174efc79dc47c1aand pass with the fix. The failures were checked for their specific expected causes, including false success, wrong error classification, and an unwanted third request.Built-binary checks against a local interrupted HTTP fixture confirm exit 7,
network.error, and empty stdout for failed first/later pages in JSON and text modes. Separate agent reviews reran the full CLI checks and tested complete-looking JSON followed by short Content-Length, an unterminated chunked body, and a corrupt gzip checksum. Those transport probes fail on baseline and pass with this fix.Existing successful merge, server-capped pagination, non-paginated fallback, and non-GET controls remain green. Successful paginated text output has a pre-existing
FormatOptions.Emitlimitation; this change leaves it unchanged and makes the original read error take precedence when a transfer fails.Scope: the full default CLI suite includes its acceptance contracts. The root backend, frontend, standalone SDK test suite, live
acceptance_e2esuite were not run locally; native macOS/Windows execution was initially left to upstream CI. Fixtures use local HTTP/fake services; no live providers or real credentials were used. No kernel-level network isolation is claimed.Hosted CI: source-bound validation passed.
Upstream CI subsequently passed on this head: CLI build, race tests and vet on Linux, macOS and Windows, plus CLI golangci-lint.
Checklist
AI assistance: coding agents prepared the patch, tests, and reviews. No personal human review is claimed.