Skip to content

Exit 3 from whoami when the API rejects the stored sign-in - #262

Merged
Gorka Gonzalo (d0ubl3g) merged 1 commit into
devfrom
fix/258-whoami-rejected-exit
Oct 31, 2026
Merged

Gorka Gonzalo (d0ubl3g) merged 1 commit into
devfrom
fix/258-whoami-rejected-exit

Conversation

@d0ubl3g

Copy link
Copy Markdown
Contributor

hodeishield whoami exited 0 when the API rejected the stored sign-in, so a script could not tell that it was signed out.

Change

  • A 401 from GET /v1/me, or a failed token refresh, now ends with the existing not-authenticated exit code (3) and its sign-in hint.
  • The local details and the warning are still printed, and --json keeps the API fields as null.
  • A network error or a 5xx answer still exits 0, as before.
  • README (the whoami paragraph and the exit-code table) and CHANGELOG updated.

Tests

  • Contract tests: a rejected credential exits 3 in JSON and table output; a failing or unreachable API still exits 0.

cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo xtask codegen --check and cargo test --workspace pass (378 tests).

whoami asked the API who the credential is and, when that failed for any
reason, printed a warning and exited 0. A script checking whether a profile
is signed in could not tell a revoked or rejected sign-in from an API that
cannot be reached.

When GET /v1/me answers that the credential is not accepted (401, or a
refused refresh), whoami now still prints the local details and the warning,
leaves the API fields null, and exits 3 with the same sign-in hint as every
other command. An API that is unreachable or fails on its side (network,
5xx, timeout) still gives exit 0. The README and the changelog describe both
cases.

Closes #258

Signed-off-by: d0ubl3g <48954024+d0ubl3g@users.noreply.github.com>
@d0ubl3g
Gorka Gonzalo (d0ubl3g) merged commit b0188e8 into dev Oct 31, 2026
23 checks passed
@d0ubl3g
Gorka Gonzalo (d0ubl3g) deleted the fix/258-whoami-rejected-exit branch October 31, 2026 19:41
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 participant