Skip to content

Bedrock /connect forces API key prompt, breaks IAM credential chain auth #29499

Description

@Modzybear

Description

/connectamazon-bedrock has no plugin-defined auth methods, so it falls through to the generic "Enter your API key" prompt with no way to skip. Users authenticating via IAM credentials (access keys, profiles, instance roles) must enter a dummy value.
That dummy value gets stored in auth.json and treated as a bearer token on next bootstrap — the custom handler sets process.env.AWS_BEARER_TOKEN_BEDROCK to the dummy value, which skips the credential chain entirely. The SDK sends the dummy string as a bearer token and Bedrock rejects it:
Forbidden: {"Message":"Invalid API Key format: Must start with pre-defined prefix"}
Workaround: rm ~/.local/share/opencode/auth.json and restart opencode.
Additionally, the autoload gate in provider.ts requires explicit env var signals (AWS_ACCESS_KEY_ID, AWS_PROFILE, etc.) — EC2 instance profiles via IMDS and default ~/.aws/credentials profiles without AWS_PROFILE set cannot autoload.

Plugins

None

OpenCode version

1.15.11

Steps to reproduce

  1. Set AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY in env (or have an AWS profile configured)
  2. Run opencode, verify Bedrock models work
  3. Run /connect, select amazon-bedrock
  4. Enter any string (e.g. test) in the forced API key prompt
  5. Select a model
  6. Send a message — get 403 Forbidden: Invalid API Key format
  7. Switching models or restarting opencode reproduces the error until auth.json is deleted

Screenshot and/or share link

N/A

Operating System

Ubuntu 22.04 (EC2)

Terminal

VS Code integrated terminal / bash

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions