Improve error message on auth host mismatch#5661
Closed
radakam wants to merge 1 commit into
Closed
Conversation
When workspace.host does not match the host of the selected profile, render a located, multi-line diagnostic (file:line:col) that names the profile and both hosts and suggests a matching profile when one exists, instead of an opaque "cannot resolve bundle auth configuration" error. Detection is centralized in a typed databrickscfg.HostMismatchError, and the rich diagnostic is rendered at the configureBundle choke point so it applies to all bundle commands.
Collaborator
Integration test reportCommit: b359606
20 interesting tests: 13 SKIP, 7 RECOVERED
Top 26 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
Turn the bundle host/profile mismatch error into an actionable, located diagnostic.
libs/databrickscfg/ops.go: extract detection into a typedHostMismatchError(configured host, profile host, profile name, suggested profile).ValidateConfigAndProfileHostreturns it; itsError()string is byte-for-byte unchanged, so the existing enforcement path and its tests don't move.cmd/root/bundle.go: inconfigureBundle, match the typed error (errors.AsType) and render adiag.Diagnosticwithworkspace.host(andworkspace.profilewhen it's set in the files) locations + a multi-lineDetail.Before:
After:
Why
Fixes DECO-7598. The previous message was single-line and never said where the conflicting host came from. (The "suggest a matching profile" hint already existed; this change keeps it but makes the whole error multi-line and points at the config locations.)
Two decisions worth a reviewer's attention:
configureBundle, not a validate mutator?configureBundleis the one place the workspace client is first built for every bundle command (deploy/destroy/validate/run), and it already logs the error there — before theInitializemutator pipeline runs. Putting the rendering anywhere later would be dead code.databrickscfg), and the bundle layer (which has thedynconfig tree) adds locations/Detailon top. No string-matching on error text.Scope notes: the message is unchanged for non-bundle callers that hit the libs path directly (they still get
Error()). The original panic in the ticket is already gone on this path (usesWorkspaceClientE+logdiag) and is tracked separately by DECO-4237.Tests
libs/databrickscfg/ops_test.go: unit tests forHostMismatchError(match, mismatch with/without a suggested profile).cmd/root/bundle_test.go: updated the two mismatch expectations to the new diagnostic (locations + detail).acceptance/auth/bundle_and_profile: regenerated golden — coversbundle validatewith-pand-t/-p, showing both the "suggested profile" and "no suggestion" variants../task fmt,./task checks,./task lint-qclean;go testfor the touched packages passes.