[Bug] Newer install breaks AWS SA Impersonation for Vertex AI Authentication
What happened?
Our automation updated from Gemini CLI v0.16.0 to v0.18.4 and now Gemini CLI no longer connects properly to the Vertex AI API endpoint, instead it only hits the Security Token Service API and produces a 400 error that presents as the following error in the CLI:
[API Error: Error code invalid_grant: Received invalid AWS response of type InvalidClientTokenId with error message: The security token included in the request is invalid.]
What did you expect to happen?
Gemini CLI Vertex AI ADC Authentication to continue working as previously proven with v0.16.0 (installing v0.16.0 without changing anything else corrects the problem).
Client information
Client Information
Run gemini to enter the interactive CLI, then run the /about command.
> /about
╭─────────────────────────────────────────────────────────────╮
│ │
│ About Gemini CLI │
│ │
│ CLI Version 0.18.4 │
│ Git Commit 2e8d7831c │
│ Model auto │
│ Sandbox no sandbox │
│ OS linux │
│ Auth Method vertex-ai │
│ GCP Project xe-uxe-supportshell-gc-prod │
│ │
╰─────────────────────────────────────────────────────────────╯
Login information
I am a system admin for an AWS EC2 instance that my enterprise users access for troubleshooting issues, so in order to provide enterprise level access to Gemini CLI, I:
- configured a Google Cloud Project with a Service Account with access to the Vertex AI API
- Created a Workload Identity Pool
- Created an AWS IAM Profile to impersonate the SA
- Provided the configurations necessary for the EC2 instance to connect to the Google Cloud Project
Anything else we need to know?
No response
Found possible duplicate issues:
- #7478
If you believe this is not a duplicate, please remove the status/possible-duplicate label.
Hi @TheDiemer, the error you provided seems like an AWS error not a gemini cli one. Also in your environment do you have
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"
set ?
It does seem like an AWS error, but with nothing else changing on the AWS side, and things resuming functionality by just downgrading from v0.18.4->v0.16.0, I can't point a finger there.
Yeah, we do have those values set correctly (and that also doesn't change)
Hi, I just wanted to check back in here to see if there were any other ideas on what code or tools I could review to investigate what happened. As I noted above, the only thing that happened was a newer version of Gemini CLI was installed (v0.18.4) and suddenly the authentication configured produced these AWS errors. Reinstalling v0.16.0 (the initially tested version) was the ONLY thing changed to fix the issue and we haven't seen it since.
First, I did want to note that this remains broken with a Newer version (v0.20.0) which was tested in our environments today.
To Help with the bug some, I used some suggestions from Gemini 3 to dig into this more today.
It suggested that the newer versions of IMDS might've impacted this and provided some AWS commands to check on things that would impact it. One of those was setting the hop limit to 2 on AWS for the EC2 instance: "HttpPutResponseHopLimit": 2. This gave me a new error, shifting the response gemini cli gave to [API Error: Unexpected end of JSON input], but since thats still an error, we dug further, using the gcloud cli tool to check on permissions as it uses the same authentication pattern (but is more direct).
Unfortunately, gcloud worked just fine and gave me the access token I expected, which brings things back to Gemini CLI's changes as the problem.
In addition, Gemini 3 suggested we try disabling Telemetry (suggesting something might've changed there, too, that could cause Gemini CLI to send some communications before auth was verified), but 1) thats not going to be a valid workaround for our environment, and 2) it also didn't work.
Please let me know if there are any settings or tweaks we could try to investigate what might be going wrong here, because until we can fix this, we are trapped on v0.16.0
It looks like v0.17.1 works too.
I’m not sure if this is relevant, but the same issue occurs when using the Google Gen AI SDK (Node.js) through Vertex AI with Workload Identity Federation from AWS. For now, the only solution is to downgrade the version of the SDK.
Hi, all are you still encountering this error ?
Still broken with @google/[email protected] for me.
Hi @galz10, yes, my environment still sees this with newer versions (I tested with 0.25.1 today).
Although, I will note that David Vo was correct that 0.17.1 seems to exhibit the expected behavior that I see with 0.16.0, in case that helps.
I’m not sure if this is relevant, but the same issue occurs when using the Google Gen AI SDK (Node.js) through Vertex AI with Workload Identity Federation from AWS. For now, the only solution is to downgrade the version of the SDK.
This is definitely relevant, we use the same package to handle authentication in the CLI. @daniel-bfo101090 can you please specify what versions worked last and from which version it started breaking on the Google Gen AI SDK
@gsquared94 Thank you for confirming. The version we are experiencing the issue with is Ver. 1.26.0. I have already reported an issue on js-genai. https://github.com/googleapis/js-genai/issues/1216
Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.
It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.
Thank you for your contribution!
Not certain which version fixed it, but as of v0.32.1, the authentication issues have been fixed, so this can stay closed (just wanted to share the tested update).