Skip to content

[mason] Clearer, actionable auth error messages - #522

Open
akansal2 wants to merge 3 commits into
databricks:mainfrom
akansal2:mason-clearer-auth-errors
Open

[mason] Clearer, actionable auth error messages#522
akansal2 wants to merge 3 commits into
databricks:mainfrom
akansal2:mason-clearer-auth-errors

Conversation

@akansal2

@akansal2 akansal2 commented Sep 3, 2026

Copy link
Copy Markdown

What did you change, and why?

Change: Fix Mason's confusing auth errors. The CLI wrapped every WorkspaceClient failure with a fixed hint — Check your profile (databricks auth login --profile <name>) or pass --profile — that often didn't match the real failure and pointed at the wrong command.

Why: From the custom-agent bug bash: "Auth error confusing", "Error message inconsistencies" (same command → two different messages; user had to unset a stray token), and Ann's mason mcp list where the fix was mason login, not databricks auth login.

Approach (deliberately not string-matching the SDK error, which is brittle across SDK versions):

  • Keep surfacing the SDK's own error text verbatim (it already flows through, e.g. … use --profile, Env: DATABRICKS_TOKEN).
  • Replace the misleading fixed hint with one always-valid next step for every failure mode: mason login — mirroring the existing wrap_api_error pattern (pass the upstream message through, add a supplemental hint).
  • The only extra signal is a structural env check (DATABRICKS_TOKEN set?) — the one override the SDK message doesn't make obvious, and the root cause of the "unset my token" report.
  • The scaffolded agent templates' startup check (_check_databricks_auth, langgraph + openai) gets the same single-command guidance.

Pairs with a follow-up PR that makes mason login authenticate on its own (so no separate databricks auth login is ever needed).

How do you know it works?

Testing: python -m py_compile on all changed modules (clean). Added unit tests in errors_test.py covering auth_hint for the default, explicit-profile, and stray-DATABRICKS_TOKEN cases. Full unit suite runs in CI. Draft until CI is green.

Surface the SDK's auth error verbatim (as before) and replace the misleading
fixed hint (`databricks auth login ...`) with a single, always-valid next
step: `mason login`. Instead of matching on the SDK's error text (brittle
across SDK versions), mirror wrap_api_error — pass the upstream message
through and add one supplemental hint — plus a structural DATABRICKS_TOKEN
env check to flag the one override the SDK message doesn't make obvious. The
scaffolded agent templates' startup auth check gets the same one-command
guidance.

Co-authored-by: Isaac <no-reply@databricks.com>
@akansal2

akansal2 commented Sep 3, 2026

Copy link
Copy Markdown
Author

Pairs with #523, which makes mason login the single auth command these hints point to.

The startup auth message named the multi-process detail ('make sure the agent
process sees it') and the Apps substrate ('for a deployed app') — both
implementation details Mason hides. Reduce it to the action: log in with
mason login, then set DATABRICKS_CONFIG_PROFILE (or HOST/TOKEN). Drops the
now-unused os import.

Co-authored-by: Isaac <no-reply@databricks.com>
@akansal2
akansal2 marked this pull request as ready for review September 3, 2026 16:56
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