Fix VertexAI scope argument for GCE credentials #520
+39
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
TypeError: Expected Array or String, got Hashwhen using VertexAI provider on Google Compute Engine with default credentials.Problem
Google::Auth.get_application_defaultexpectsscopeas a positional argument, not a keyword argument. The current code passes:Ruby interprets
scope: [...]as passing a Hash{scope: [...]}to the first positional parameter. The signet gem then raises:This only manifests when running on GCE with default credentials (not with service account key files, where authentication works differently).
How We Found This
We were running a Rails app on a GCE VM using RubyLLM 1.9.1 with the VertexAI provider. Episode processing jobs that called
RubyLLM.chat(model: "gemini-2.0-flash", provider: :vertexai).ask(prompt)were failing with:We traced the error to
signet-0.21.0/lib/signet/oauth_2/client.rb:The
new_scopewas a Hash{scope: [...]}instead of an Array.Minimal Reproduction
On a GCE VM with the
cloud-platformOAuth scope:To verify the root cause:
Solution
Change from keyword to positional argument:
Testing
get_application_defaultis called with an Array, not a Hashcloud-platformOAuth scopeEnvironment