Skip to content

Blank shell Anthropic credentials in Claude settings - #1287

Merged
billiam-wang merged 6 commits into
mainfrom
blank-shell-anthropic-credentials
Oct 28, 2026
Merged

billiam-wang merged 6 commits into
mainfrom
blank-shell-anthropic-credentials

Conversation

@billiam-wang

Copy link
Copy Markdown
Collaborator

Worktree: ug-blank-shell-anthropic-credentials | Branch: blank-shell-anthropic-credentials

What did you change, and why?

A shell ANTHROPIC_AUTH_TOKEN/ANTHROPIC_API_KEY (e.g. from LiteLLM) outranks apiKeyHelper, so Claude sent it to the AI Gateway and failed with a 401 (ES-2297582). ug now writes both as "" next to ANTHROPIC_BASE_URL: always in ucode-settings.json, and in managed-settings.json from ug configure. The user's shell is untouched. Like the header mod, a plain launch never re-adds them to the managed file, so a second writer that drops them isn't fought with sudo (CUJ 8). Supersedes the drop-in approach in #1185.

How do you know it works?

11 new unit tests. Live, with fake keys in the shell: ug claude and bare claude both answered. With the managed blanks removed, a launch made no sudo write and still worked. Control: bare claude without the blanks reproduced the exact 401.

This pull request and its description were written by Isaac.

…ell credentials can't outrank apiKeyHelper

Claude Code ranks both shell variables above apiKeyHelper and the subscription login,
so a LiteLLM-style key was sent to the gateway (401). A settings env value beats the
shell's, so ug writes both as empty strings. ucode-settings.json always has them
(relayed included); the managed file gets them from ug configure only, like the header
mod, so a second writer that drops them is not fought on every launch.

Co-authored-by: Isaac <no-reply@databricks.com>
@billiam-wang
billiam-wang marked this pull request as ready for review October 26, 2026 23:05
@billiam-wang

Copy link
Copy Markdown
Collaborator Author

/ug-review

Comment thread src/ucode/agents/claude.py Resolved
Comment thread src/ucode/agents/claude.py Resolved
Comment thread src/ucode/doctor.py Resolved
Comment thread src/ucode/doctor.py Resolved
Comment thread tests/test_claude_credential_blanks.py Resolved
Comment thread tests/test_claude_credential_blanks.py Resolved
Comment thread tests/test_claude_credential_blanks.py Resolved
…igure flag, doctor info, tighter tests

Co-authored-by: Isaac <no-reply@databricks.com>
Comment thread src/ucode/doctor.py Resolved
Comment thread src/ucode/agents/claude.py Resolved
Add native_claude/test_credentials.py: the CI-pinned Claude runs one turn
against a fake API with shell ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN set.
With ug's blanks it sends the apiKeyHelper token, or on the relayed path its
OAuth token, with no empty header; control cases show the shell wins
without them. Run it in the Claude mod CI job, and share the binary
fixture through a conftest.

The doctor note now says Claude launched via ug ignores the variable and
names DATABRICKS_BEARER and `ug configure --use-pat` for using your own token.

Co-authored-by: Isaac <no-reply@databricks.com>
@billiam-wang
billiam-wang requested a review from rohita5l October 27, 2026 19:47
@billiam-wang
billiam-wang disabled auto-merge October 28, 2026 02:16
@billiam-wang
billiam-wang added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 2fc6985 Oct 28, 2026
104 of 112 checks passed
@billiam-wang
billiam-wang deleted the blank-shell-anthropic-credentials branch October 28, 2026 03:11
billiam-wang added a commit that referenced this pull request Oct 28, 2026
Resolve against #1287, which renamed the header-mod flag to
`_explicit_configure` and added a UG_HEADERS launch trigger: keep this
branch's rule that only `ug configure` adds the mod, under the new name, and
rename the flag in this branch's header-mod test.

Co-authored-by: Isaac <no-reply@databricks.com>
billiam-wang added a commit that referenced this pull request Oct 28, 2026
Resolve against #1287: keep this branch's shared `claude_managed_env`
fixture and carry over #1287's rename of the header-mod flag to
`_explicit_configure`. #1287's new credential-blank tests imported the
old module-level helper, so they now use the fixture.

Co-authored-by: Isaac <no-reply@databricks.com>
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