Skip to content

Ensure errors don't cause silent failure, make authN failure messages friendlier#89

Open
jeri-temporal wants to merge 4 commits into
mainfrom
jeri/friendly_errors
Open

Ensure errors don't cause silent failure, make authN failure messages friendlier#89
jeri-temporal wants to merge 4 commits into
mainfrom
jeri/friendly_errors

Conversation

@jeri-temporal

@jeri-temporal jeri-temporal commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What was changed

  • Moved CommandHarnes from integration-only commands_test.go to common_test.go so it could be used for unit tests as well
  • Ensure failures are printed to stderr when error logging is disabled. This prevents the cloud CLI from failing silently
  • Introduce the FriendlyError type as a means of marking error messages for direct display without appending the full error chain
  • Use a custom interceptor to capture errors from within the gRPC call chain and wrap them around errors stored on the context struct. This allows errors.Is/errors.As to find FriendlyErrors that occur inside gRPC callback methods

Why?

Running commands while not logged in (including temporal cloud whoami) produces no output and a non-zero exit code, and other errors are similarly swallowed unless handled specifically within each command.

Checklist

  1. Closes CLDDX-141

  2. How was this tested:
    make, make test, make test-integration, verified that running commands like temporal cloud whoami or temporal cloud namespace list without being authenticated prints no login session found, please run `temporal cloud login`

  3. Any docs updates needed?
    No


Note

Medium Risk
Changes global CLI failure handling and OAuth/API-key error propagation for all cloud commands, though behavior is limited to error display and wrapping with added unit tests.

Overview
Fixes silent non-zero exits when commands fail (e.g. unauthenticated whoami) by tightening the default Fail path: FriendlyError messages go to stderr without the full chain, and if error logging is off, the full error is still printed to stderr.

Auth/token failures in GetAPIKey now return FriendlyError (clear login/reset guidance) and stash the original error on the gRPC context via errorContext / grabOriginalErrorInterceptor + GraftErrors, so handlers can still use errors.Is / errors.As through gRPC-wrapped failures.

whoami uses GetCloudClient for consistency with other commands. Tests add CommandHarness reuse (moved out of integration-only file), subprocess checks that stderr is user-facing (not slog level=), and unit coverage for friendly errors and error grafting.

Reviewed by Cursor Bugbot for commit 0cd97f6. Bugbot is set up for automated code reviews on this repo. Configure here.

@jeri-temporal jeri-temporal requested a review from a team as a code owner July 1, 2026 20:15
@jeri-temporal jeri-temporal reopened this Jul 6, 2026
@jeri-temporal jeri-temporal force-pushed the jeri/friendly_errors branch from 4dd7046 to dde51ca Compare July 6, 2026 18:03
@anekkanti

Copy link
Copy Markdown
Member

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0cd97f6. Configure here.

// ServiceAccount) along with the associated API key, if any.
func (c *CloudWhoamiCommand) run(cctx *CommandContext, _ []string) error {
cloudClient, err := cctx.BuildCloudClient(c.ClientOptions)
cloudClient, err := cctx.GetCloudClient(c.ClientOptions)

@anekkanti anekkanti Jul 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whats the purpose of this change?

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.

2 participants