Skip to content

google-vertex: AWS workload identity federation fails on google-auth-library 10.5.0 (fixed in 10.6.1) #66427

Done

Description

@alejandroBallesterosC

Description

packages/ai pins google-auth-library to exactly 10.5.0. However, that version cannot authenticate through Workload Identity Federation from AWS when the AWS role credentials come from a metadata endpoint. So for those setups, the google-vertex provider cannot authenticate at all.

Cause: There's a bug in google-auth-library versions 10.0.0 through 10.5.0 that was fixed in version 10.6.1: the role's credentials (.../meta-data/iam/security-credentials/<role>) are requested without responseType: 'json' so gaxios only parses the body as JSON when the response is labelled application/json. However, the metadata endpoint serves the response as text/plain so the library gets a string and reads AccessKeyId, SecretAccessKey and Token as undefined. It then signs the AWS GetCallerIdentity request without valid keys, and the token exchange fails with AWS InvalidClientTokenId.

In Opencode the ADC error handler in packages/ai/src/providers/google-vertex-shared.ts replaces that error with Missing auth credential: Google Application Default Credentials so the failure looks like missing credentials instead of a library bug.

This bug is fixed in google-auth-library 10.6.1 (googleapis/google-cloud-node-core#901; reported in googleapis/google-cloud-node-core#898).

Could packages/ai move to google-auth-library 10.6.1 or later?

Plugins

None

OpenCode version

2.4.1 (dev pins google-auth-library 10.5.0 also)

Steps to reproduce

  1. Create a Workload Identity Federation credential config for an AWS provider: gcloud iam workload-identity-pools create-cred-config ... --aws It reads role credentials from an endpoint.
  2. On a machine whose AWS role is served at that endpoint, with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY unset, set GOOGLE_APPLICATION_CREDENTIALS to that config
  3. Send a prompt to any google-vertex model. It fails with Missing auth credential: Google Application Default Credentials.

Screenshot

No response

Operating System

Not OS-specific

Terminal

Ghostty

Activity

  1. added
    area/providers
    type/bug
    version/v2
    status/repro-simulated
    on Nov 25, 2026
  2. Guembri01 commented on Nov 25, 2026

    @Guembri01

    Took this: the pin was 10.5.0, so the fix is the version bump you asked for.

    packages/ai now pins [email protected] — the current 10.x rather than 11.x, so the AnyAuthClient / GoogleAuthOptions types this package imports keep their major. bun install resolves it (the lock records 10.9.1 and its own transitive set), packages/ai is 2304 tests green, and typecheck is clean.

    What I can't do from here is exercise the failing path: WIF from AWS needs a role served from a metadata endpoint. The PR says that plainly instead of implying it was tested against AWS.

    Branch google-auth-library-10. PR creation is currently refused for this account (the GraphQL API returns FORBIDDEN: does not have the correct permissions to execute CreatePullRequest, which REST hides as 404), so it is ready as a branch with the body written until that clears.

  3. LyleLiu666 commented on Nov 25, 2026

    @LyleLiu666

    Thanks, Guembri01, for preparing the 10.9.1 upgrade. I replayed the reported failure on your public commit 049aaaec and its parent fb56d1cd. Tested commit

    With 10.5.0, the text/plain IMDSv2 role response led to a rejected token exchange and OpenCode reported missing Google ADC. With 10.9.1, the exchange succeeded and the Vertex provider returned the fixture response. AWS environment-variable credentials passed on both commits and bypassed IMDS. Both paths also passed after installing an npm tarball built from your branch.

    The replay used OpenCode's actual Vertex provider with synthetic credentials and local IMDSv2, Google STS, and Vertex endpoints.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/providersstatus/repro-simulatedtype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions