claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

GitHub App Installation Blocked: Unexpected ANTHROPIC_API_KEY Secret Conflict

Open 5hirish opened this issue 8 months ago • 5 comments

Bug Description I have successfully installed Claude Code in one of my Github repositories using /install-github-app. Except when I go to install it to my second repository using the same /install-github-app it unexpectedly informs me that - "ANTHROPIC_API_KEY already exists in repository secrets!" and automatically skips to "Create a new secret with a different name" There main issue here is -

  1. I don't have an ANTHROPIC_API_KEY secret in my repository (Confirmed via gh secret list --repo username/repo | grep ANTHROPIC_API_KEY)
  2. Even if it thinks so, it doesn't even allow me to select the option "Use the existing API key" (Probably skips this option because of 1) I am not sure how to resolve this. I am stuck in a loop. And I can access the value of my ANTHROPIC_API_KEY or create a new API Key from API Console since the "Claude Code" Workspace doesn't allow it.

Environment Info

  • Platform: darwin
  • Terminal: cursor
  • Version: 1.0.35
  • Feedback ID: 3402973b-2fc3-45b0-94c7-b91b0685ae9a

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:882:11)\n    at execSync (node:child_process:954:15)\n    at TZ (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:700:3921)\n    at file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:622:9014\n    at Q (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:17199)\n    at VX (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:622:8160)\n    at nS (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:622:7241)\n    at f9 (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:622:11408)","timestamp":"2025-06-30T19:35:51.756Z"},{"error":"Error: 1: ENOENT \n    at ux6 (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1325:4797)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async mx6 (file:///Users/work/.nvm/versions/node/v23.9.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1325:2578)","timestamp":"2025-06-30T19:35:54.024Z"}]
Claude CLI Diagnostic
 Currently running: npm-global (1.0.35)
 Path: /Users/work/.nvm/versions/node/v23.9.0/bin/node
 Invoked: /Users/work/.nvm/versions/node/v23.9.0/bin/claude
 Auto-updates: No
 Config install method: unknown
 Config auto-updates: true
 Update permissions: Yes
 Recommendation: Run '/migrate-installer' to enable auto-updates
 This migrates to a local installation in ~/.claude/local

5hirish avatar Jun 30 '25 19:06 5hirish

Some investigation later -

On performing security find-generic-password -s "Claude Code" -a $USER I get nothing. But it seems like the API key is stored under "Claude Code-credentials" (not just "Claude Code").

5hirish avatar Jun 30 '25 20:06 5hirish

@5hirish that's pretty odd. The way we check for existing secrets is by running gh secret list --app actions --repo ${userNameOrOrgName}/${repoName} and search for ANTHROPIC_API_KEY.

Just to help with debugging, when you do /install-github-app are you typing in a repo name manually or using the default suggested one?

ashwin-ant avatar Jun 30 '25 21:06 ashwin-ant

Yes, I found it odd too. And I am able to reproduce it each time. I am using the default suggested one. As in the git repo that Claude Code finds in the current director.

5hirish avatar Jun 30 '25 22:06 5hirish

@5hirish just as a sanity check, you mentioned running gh secret list --repo username/repo. Can you try manually running gh secret list --app actions --repo username/repo and seeing if it errors? I think I may have found the issue here, but would like to confirm a theory.

ashwin-ant avatar Jun 30 '25 23:06 ashwin-ant

I ran the command and it doesn't error and shows me the secrets in my repo and ANTHROPIC_API_KEY is not one of it.

5hirish avatar Jul 01 '25 00:07 5hirish

Hey @ashwin-ant , let me know if you need any more information.

5hirish avatar Jul 03 '25 05:07 5hirish

This was resolved for me by updating to the latest version of CC

brycelund avatar Jul 16 '25 15:07 brycelund

Yes seems like it is working for me too. I am closing down this issue for now then. If anyone faces similar issue, please feel free to reopen it.

5hirish avatar Jul 17 '25 19:07 5hirish

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Jul 31 '25 14:07 github-actions[bot]