Skip to content

fix(no-ticket): whoami exits 1 when not authenticated#321

Merged
BartoszBlizniak merged 1 commit into
masterfrom
fix/whoami-exit-code
Jul 15, 2026
Merged

fix(no-ticket): whoami exits 1 when not authenticated#321
BartoszBlizniak merged 1 commit into
masterfrom
fix/whoami-exit-code

Conversation

@BartoszBlizniak

Copy link
Copy Markdown
Member

Description

cloudsmith whoami always exited with code 0, even when the request was anonymous. Scripts and CI pipelines could not rely on the exit code to verify credentials and instead had to parse --output-format json for "is_authenticated": false.

The command now exits with code 1 when is_authenticated is false and 0 when true, across all output formats (human, json, pretty_json).

Includes new tests for the whoami command (none existed previously): authenticated and anonymous cases.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

(Release notes for this will be added at the end of merging the draft PRs)
Behavior change — flag in release notes: callers that run whoami while unauthenticated and expect exit 0 will now receive exit 1. This is the intended, correct behavior, since the exit code should reflect authentication status.

The whoami command previously always exited 0, even for anonymous
(unauthenticated) requests, so scripts and CI pipelines had to parse
the JSON output to detect authentication status. It now exits with
code 1 when is_authenticated is false and 0 when true, across all
output formats. Output is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BartoszBlizniak BartoszBlizniak marked this pull request as ready for review July 15, 2026 10:06
@BartoszBlizniak BartoszBlizniak requested a review from a team as a code owner July 15, 2026 10:06
Copilot AI review requested due to automatic review settings July 15, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the cloudsmith whoami CLI command to use its exit code to reflect authentication status, enabling scripts/CI to reliably detect missing credentials without parsing JSON output.

Changes:

  • Exit with code 1 when the API response indicates the request is anonymous (is_authenticated == false), and 0 when authenticated, including JSON output mode.
  • Add new unit tests for whoami covering authenticated vs unauthenticated behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cloudsmith_cli/cli/commands/whoami.py Updates whoami to exit non-zero when unauthenticated (including when emitting JSON).
cloudsmith_cli/cli/tests/commands/test_whoami.py Adds new tests to validate exit codes and output payload for authenticated/anonymous cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cloudsmith_cli/cli/tests/commands/test_whoami.py
@BartoszBlizniak BartoszBlizniak merged commit f277fa7 into master Jul 15, 2026
41 checks passed
@BartoszBlizniak BartoszBlizniak deleted the fix/whoami-exit-code branch July 15, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants