api: fix --all returning no output on single-page results - #78
Merged
Conversation
paginateResponse read the initial response body to check for additional pages but did not restore it when there were none (or the payload was not a paginated collection). The drained body then failed to render, so `api --all` returned no output on single-page results. Restore the buffered body before returning on that path. Adds a test covering --all against a single-page response.
jordanenglish
marked this pull request as ready for review
July 13, 2026 17:56
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
tfctl api --allreturns no output when the result fits in a single page. InpaginateResponse, the initial response body is read in full to look for anextpagination link. On the single-page path (nonextlink, or the payloadis not a paginated collection) the function returned the response without
restoring that drained body, so rendering saw an empty body. In practice this
surfaced as a
not a JSON:API envelopeerror rather than the expected result.This restores the buffered body before returning on that path, mirroring what
the multi-page path already does when it re-wraps the merged body.
Example Output
Before (against a resource whose result fits on one page):
After:
PR Checklist
npx changie newor install changie to prepare a new changelog entry for the next set of release notes..changes/unreleased/BUG FIXES-*.yaml(kind: BUG FIXES).--json— Force machine readable output to stdout. Does not apply to stderr.--markdown— Force markdown output to stdout. Does not apply to stderr.--dry-run— Don't make any actual writes or other mutations. Describe what would have changed to stderr.--quiet— Don't render output to stdout.--json/--markdown/--quiet) render as they would for a non---allrequest.--dry-runis not applicable toapiGET pagination.make gen/screenshotif the root command output changes.Autocompletefield to positional arguments and flags to assist shell autocomplete.PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.