Skip to content

1.0 polish: structured output and command edge cases (part of #29) - #36

Open
quinnmil wants to merge 1 commit into
mainfrom
29a-output-correctness
Open

quinnmil wants to merge 1 commit into
mainfrom
29a-output-correctness

Conversation

@quinnmil

Copy link
Copy Markdown
Contributor

Addresses part of #29 (tracking issue). Companion to #35, which handles chart rendering, docs and CI — this branch merges that one in as well, so both land together cleanly (no conflicts between the two on the shared files they both touch).

-n/--limit now applies to --json output too

Every list command applied the limit only to the human table; -n had no effect on --json (or, since TOON's removal, on piped output — the same code path). Introduced limitSlice, called before structuredOutput everywhere: apps list, endpoints list, jobs list, traces list (endpoint and job), errors list, errors occurrences, anomalies list, all four usage modes, and insights list/insights show (which didn't limit in either mode before). Totals and percentages are still computed over the full result set — -n only changes which rows ship.

Other fixes

  • scout usage --billing-period --json now includes the billing period and server-reported total (previously identical in shape to a plain --from/--to run).
  • jobs metrics --type latency --json no longer carries a total key that's actually execution time, not latency — renamed to execution_time_total to match what it is.
  • scout usage --app <id> (without --by-day) now actually filters to that app instead of silently returning all apps.
  • scout anomalies --endpoint now accepts the same forms as every other --endpoint flag (Base64 id, plain endpoint name) in addition to the fully-scoped name — previously the base64 form silently matched nothing.
  • Empty flag values (--endpoint '', --job '', etc.) now error clearly client-side instead of reaching the server.
  • Malformed --job values (including a bare job class name pasted without its queue) now error client-side with guidance instead of a raw API error (500).
  • scout auth logout on a fresh install (no config directory yet) is now a no-op success instead of an error.
  • --from/--to now reject a reversed range and unreasonable relative durations (negative, or past a 5-year bound).
  • --app 0 (or negative) now gives a clear "invalid --app value" error instead of "no app specified."
  • scout traces show <job-trace-id> 404s now explain that job traces have no detail endpoint.
  • scout errors show omits the Count: line when it's 0 rather than showing a misleading zero.
  • scout insights show now prints fields in sorted (deterministic) order, indents nested objects instead of Go's map[...] syntax, and renders nil/empty values as .

Test plan

  • gofmt -l ., go vet ./..., go build, go test -race ./..., golangci-lint run ./... — all clean
  • New/updated tests across cmd/root_test.go, cmd/anomalies_test.go, cmd/insights_test.go, cmd/usage_test.go, cmd/traces_test.go, cmd/jobs_test.go, internal/timeutil/parse_test.go, internal/config/config_test.go, internal/api/jobs_test.go
  • Live verification against real data: -n under --json for several commands, the anomalies endpoint fix (plain name and full-scoped name both return the same results), a bare job class name rejected cleanly, reversed/negative timeframes rejected on a timeframe-scoped command, --app 0 rejected, auth logout on a fresh config directory

🤖 Generated with Claude Code

https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS

@quinnmil quinnmil linked an issue Sep 10, 2026 that may be closed by this pull request
36 tasks
Squashed for a clean rebase onto main after v0.5.0 landed, and reverted
the changelog.d/ fragment system in favor of a direct CHANGELOG.md edit
(dropped per team discussion — more process than this repo's PR
concurrency warrants). Functional content is unchanged from the
original review.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS
@mitchh456

Copy link
Copy Markdown

This reverts the merged v0.5.0 CHANGELOG entry.

CHANGELOG.md:3 — this branch parents directly on 3aa5f56 ("Bump version to v0.5.0 (#34)"), the commit that added these lines, but the diff replaces ## [0.5.0] - 2026-09-10 and its release summary with ## Pending. On merge the file ends up with two ## Pending headings, no [0.5.0] section at all, and the PR references reverted to the numbers #34 corrected (#23#8, #24#18, #22#20, #21#19). It's a clean edit on the current file, so git reports MERGEABLE and nothing flags it.

The identical clobber is in #35, so fixing one doesn't fix the other — whichever merges second re-applies it. #32 and #33 branch from the same commit and leave [0.5.0] intact, so this isn't a stale-base artifact.

Is the CHANGELOG restructure intentional? Nothing in the description, the commit message, or #29 mentions it.

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.

1.0 polish: structured output, edge cases, docs accuracy (tracking)

2 participants