Repository navigation
fix(cli): make identity resolution and piped output diagnosable - #155
Merged
Merged
Conversation
graywolf336
force-pushed
the
fix/cli-diagnostics
branch
from
August 6, 2026 23:48
36eb620 to
b31e940
Compare
geekgonecrazy
approved these changes
Aug 6, 2026
graywolf336
force-pushed
the
fix/cli-diagnostics
branch
from
August 7, 2026 14:58
b31e940 to
bb89c64
Compare
Every command advertises "-v, --verbose Emit extra diagnostic output", and the flag was parsed into a field nothing ever read. env_logger was initialised before clap ran, so only RUST_LOG could raise the level and the documented flag did nothing at all. Scan argv for the flag before initialising, since logging has to be live before parsing (parsing itself can fail, and that trail is worth having) and a global flag's position is unconstrained. Scope the filter to `atomic`, which prefix-matches both this binary's `atomic::…` module paths — the [[bin]] name, not the atomic-cli package name — and every `atomic_*` library crate. A bare `debug` would pull in reqwest and hyper wire logging and bury the line the user came for. RUST_LOG still wins when set.
When a server profile declares no identity the client silently falls back to the global default. If that default is not the identity registered with the server, the only symptom is a 401 from the far end that names no identity at all — the local side of the mistake is invisible, so diagnosis means guessing which of several local identities was used. Log the chosen identity in both branches, say explicitly when it was a fallback rather than a binding, and name the command that fixes it. Pairs with --verbose actually working; before that these lines were only reachable through RUST_LOG.
indicatif defaults to a stderr draw target that suppresses itself off TTY. That is right for the animation — a spinner in a log file is noise — but finish_with_message goes through the same target, so the outcome line disappeared with it. A piped `atomic view switch` therefore printed nothing whatsoever: no confirmation that the switch happened, and no "N conflicts detected" warning either. Scripts, CI logs and agents saw an empty stream from a command that had done real work. Emit the message directly when the bar is hidden. Plain text, no ANSI, since the consumer is a pipe. On a TTY the bar renders it as before and the fallback stays quiet, so there is no double-print.
The undeserializable-response path quoted `&body[..200]`. Slicing a str at an arbitrary byte offset panics when the index lands inside a multi-byte character, so any error body carrying non-ASCII text — an accented name, a smart quote in a server message — could abort the CLI while it was in the middle of reporting a different failure. Walk back to a character boundary instead. Raise the preview to 2000 bytes while here: 200 routinely cut off before the offending field, producing an error that named a problem the reader could not see. The full body now goes to the debug log regardless, so the bound is only about keeping the terminal readable.
graywolf336
force-pushed
the
fix/cli-diagnostics
branch
from
August 7, 2026 15:21
bb89c64 to
204c6c8
Compare
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.
Four defects found while debugging an opaque
401 Token references an identity that is not registered. Each one individually hid information the user had explicitly asked for, and together they turned a one-line misconfiguration into a long hunt.The fixes
--verbosewas a no-op — every command advertises-v, --verbose Emit extra diagnostic output, but the parsed field was never read.env_loggerwas initialised before clap ran, so onlyRUST_LOGcould raise the level. The debug lines naming the authenticating identity already existed; they were simply unreachable through the documented flag. The filter is scoped toatomic, which prefix-matches both this binary'satomic::…module paths (the[[bin]]name, not the package name) and theatomic_*libraries, so reqwest/hyper wire logging doesn't bury the answer.RUST_LOGstill wins when set.Silent fallback to the default identity — when a server profile declares no identity, the client quietly uses the global default. If that isn't the identity registered with the server, the only symptom is a 401 from the far end naming no identity at all. Now logs which identity was chosen, says it was a fallback, and names the command that binds one.
Progress completions vanished off-TTY —
indicatifhides its draw target when stderr isn't a terminal, which is right for the animation but also swallowedfinish_with_message. A pipedatomic view switchprinted nothing: no confirmation, and noN conflicts detectedwarning either. Scripts, CI logs and agents saw an empty stream from a command that had done real work.Latent panic in error reporting — the undeserializable-response path sliced
&body[..200], which panics when the cut lands inside a multi-byte character. An accented name or smart quote in a server message was enough to abort the CLI mid-report. Now walks to a character boundary; preview raised to 2000 bytes (200 routinely cut off before the offending field) with the full body at debug level.Before / after
Recreating the original broken state by removing an
identitybinding:Testing
cargo test --workspace— 0 failures.cargo fmt --checkandcargo clippy --all-targetsclean on every changed crate. Each of the four commits was checked out individually and verified to build (cargo check --workspace --all-targets) and test green, so the branch bisects cleanly and any commit can be reverted alone.Behaviour verified against live staging and production, plus a real pty to confirm the progress fix doesn't double-print on a TTY.
Six new tests cover the truncation helper, including one walking every truncation offset through multi-byte characters.
Notes
GrantSubjectTypenot acceptingeveryonewas dropped from this branch — fix(teams): accept everyone workspace grants #151 already covers it, and does so more thoroughly (it also guards the mutation helpers against the response-only variant).Not addressed (server-side)
atomic org listreturns HTTP 405 —GET /orgsisn't routed on staging or production, thoughPOST /orgsis.org member listresolves the org before validating the token, so a bad slug masks auth state entirely.