Uh oh!
There was an error while loading. Please reload this page.
fix(cli): announce truncated structured list pages on stderr - #169
Merged
Conversation
In json/toon mode PrintList suppresses the "Showing N results" footer to keep stdout byte-pure for pipelines, so a page short of the server total (e.g. the default --limit 20 of a much larger total) was indistinguishable from the whole set. PrintList now prints a "note: showing N of T total results (page P)" line on stderr when the page does not cover the total; table mode is unchanged. Also pin, at both the command and the built-binary level, that a compact list projection which cannot fit its byte budget fails hard: non-zero exit, the refusal on stderr, and nothing on stdout — so a pipeline reading stdout sees a failed call rather than an empty page.
The note fired whenever total > count, which misjudges the last page: --limit 20 --page 2 against a total of 40 printed "use --page for the rest" even though page 2 is the end. PrintList now takes the page size and computes hasMore as (page-1)*limit+count < total, so the note only appears when rows actually remain beyond the current page.
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
What
In json/toon mode,
PrintListsuppresses the "Showing N results (page P, total T)." footer to keep stdout byte-pure for jq/toon pipelines. That left a gap: a page short of the server-reported total (e.g. the default--limit 20of a far larger total) looked exactly like the whole set to anything reading stdout.PrintListnow prints anote: showing N of T total results (page P); raise --limit or use --page for the restline on stderr when the page doesn't cover the total — same pattern as the existing projection notes. Table mode is unchanged (it keeps the stdout footer); a page that covers the total prints nothing extra. This covers every paged list command that goes throughPrintList(alert list,alert-event list,incident list,change list,audit search,insight incident-list).Overflow hard-failure is now pinned by tests
A compact list projection that can't fit its 16 KiB budget already fails the command (the error propagates out of
RunE→mainexits 1 withError: projected list is …on stderr and nothing on stdout). That behavior had no command- or binary-level coverage, so this adds:TestCommandListProjectionOverflowFails(incident list+alert-event list): irreducible projection →Executereturns the byte-limit refusal and stdout stays empty.TestProjectionOverflowFailsHard(built binary against a stub server): non-zero exit code, empty stdout, refusal on stderr — so a pipeline reading stdout sees a failed call, never an empty page masquerading as "no data".TestCommandAlertListStructuredAnnouncesTruncation: the new stderr note fires on a truncated structured page, stays silent when the page covers the total, and table mode keeps its stdout footer.Verification
make check(gofmt/gci, golangci-lint,go test -race ./..., build): all green.Error: projected list is … exceeds the 16384-byte limiton stderr.