AIR CLI Integration: authenticate air get up front and fail fast#5729
Open
riddhibhagwat-db wants to merge 1 commit into
Open
AIR CLI Integration: authenticate air get up front and fail fast#5729riddhibhagwat-db wants to merge 1 commit into
air get up front and fail fast#5729riddhibhagwat-db wants to merge 1 commit into
Conversation
The get command validated authentication only lazily: Config.Authenticate (in PreRunE) merely attaches credentials, so a bad PAT or missing profile surfaced as a confusing error partway through rendering, after a run's config had already been printed. Validate the workspace client up front instead: - PreRunE maps MustWorkspaceClient failures to an actionable auth error: a missing-profile hint when no default profile is set and --profile (-p) was not passed (ErrCannotConfigureDefault), otherwise "authentication was not successful". - RunE calls CurrentUser.Me before fetching or rendering anything, so a credential that resolves locally but is rejected by the workspace fails fast with the same clear message and no partial status/config output. Co-authored-by: Isaac
air get up front and fail fastair get up front and fail fast
Contributor
Waiting for approvalCould not determine reviewers from git history. Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
Collaborator
Integration test reportCommit: 5fb2478
21 interesting tests: 13 SKIP, 7 KNOWN, 1 RECOVERED
Top 20 slowest tests (at least 2 minutes):
|
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.
Changes
Authenticate before any run status or config is fetched or printed:
MustWorkspaceClientfailure to an actionable auth error:--profile/-pnot passed (config.ErrCannotConfigureDefault) → "no default profile is set: pass --profile (-p) or configure a default profile in your .databrickscfg"CurrentUser.Mebefore fetching/rendering anything, so a credential that resolves locally but is rejected by the workspace also fails fast with the same clear message — and no partial status/config is shown.Both errors are permanent (not retryable) and, in
-o jsonmode, render as the standard error envelope (code: UNAUTHENTICATED).Why
air get JOB_RUN_IDvalidated authentication only lazily.MustWorkspaceClient(PreRunE) callsConfig.Authenticate, which merely attaches credentials (for a PAT it does no server-side check), so an invalid credential or missing profile surfaced as a confusing, generic failure partway through — after a run's config had already started rendering — instead of a clear, up-front error.Testing
TestGetRunAuthFailed— a rejectedCurrentUser.Meshort-circuits beforeGetRun(no run fetched, nothing rendered).TestAuthError— verifies the no-profile vs generic-auth message mapping (and that the cause is preserved).Mesuccess.go build ./..., the air unit tests, the air acceptance suite, and./task lint-q(0 issues) all pass.Based on
air-cli(post-#5685, so the command isair get JOB_RUN_ID).This pull request and its description were written by Isaac.