Skip to content

fix(vertex): add generative-language scope so SA-JSON model discovery works - #3922

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.26from
artickc:fix/vertex-discovery-genlang-scope
Jun 15, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.26from
artickc:fix/vertex-discovery-genlang-scope

Conversation

@artickc

@artickc artickc commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Vertex / Gemini / Vertex-Express model discovery lists the live catalog from
generativelanguage.googleapis.com/v1beta/models using a Bearer token minted by
getAccessToken() in open-sse/executors/vertex.ts. That token only requested the
cloud-platform scope, which is insufficient for the Generative Language models
listing — the call returns HTTP 403 ACCESS_TOKEN_SCOPE_INSUFFICIENT ("Request had
insufficient authentication scopes"). The discovery branch then silently falls back to
the static registry catalog (source: local_catalog, warning: "API unavailable — using local catalog"), so a Service-Account-JSON Vertex connection only ever surfaces the ~10
hardcoded registry models instead of the full live Gemini catalog.

Fix

Mint the SA OAuth token with the Generative Language scope in addition to cloud-platform:

https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/generative-language.retriever

This is harmless for execution (cloud-platform still authorizes Vertex AI /
aiplatform.googleapis.com for chat/image) and for projects that don't need the extra
scope (the token mint never validates scope availability — only the API call does).

Verification (live, real Service Account JSON)

Minted the SA token and called the exact discovery endpoint:

Token scope GET v1beta/models result
cloud-platform only (current) 403 ACCESS_TOKEN_SCOPE_INSUFFICIENT → fallback to 10 static models
cloud-platform + generative-language.retriever (this PR) 200 OK, 55 live models (gemini-2.5-flash, gemini-2.5-pro, gemini-2.0-flash, …)

(The Vertex AI publisher endpoint …-aiplatform.googleapis.com/v1beta1/publishers/google/models
returns Model-Garden/infra entries — bert, efficientnet, occupancy-analytics — not the chat
catalog, so generativelanguage remains the correct discovery source; only the token scope
was wrong.)

Scope of change

One file: open-sse/executors/vertex.ts (the getAccessToken JWT scope claim).

… works

The Vertex/Gemini/Vertex-Express model discovery branch lists the live catalog from generativelanguage.googleapis.com/v1beta/models using a Bearer token minted by getAccessToken(). That token only requested the cloud-platform scope, so the listing returned HTTP 403 ACCESS_TOKEN_SCOPE_INSUFFICIENT and discovery silently fell back to the static ~10-model registry list.

Verified live against a real Service Account JSON: the same SA token minted with the additional https://www.googleapis.com/auth/generative-language.retriever scope makes the identical call return the full live Gemini catalog (55 models: gemini-2.5-flash, gemini-2.5-pro, gemini-2.0-flash, ...).

Adding the extra scope is harmless for execution (cloud-platform still authorizes aiplatform.googleapis.com) and for projects where it isn't needed (token mint never validates scope availability).
@artickc
artickc requested a review from diegosouzapw as a code owner June 15, 2026 20:19

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the OAuth scope requested for Vertex AI in open-sse/executors/vertex.ts to include the generative-language.retriever scope alongside cloud-platform. This addition allows model discovery to successfully list the live catalog from generativelanguage.googleapis.com without encountering a 403 error. The review feedback correctly notes that, per the Repository Style Guide, modifying production code in open-sse/ requires adding or updating corresponding tests in the tests/ directory.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread open-sse/executors/vertex.ts Outdated
Comment on lines +76 to +77
scope:
"https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/generative-language.retriever",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide (Rule 9), changing production code in 'open-sse/' requires including or updating tests. Please add corresponding tests in the 'tests/' directory to cover this scope change.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.26 June 15, 2026 22:38
diegosouzapw and others added 2 commits June 15, 2026 19:39
Vertex SA tokens now mint both cloud-platform (execution) and
generative-language.retriever (live model discovery) — without the second,
discovery returns 403 ACCESS_TOKEN_SCOPE_INSUFFICIENT and falls back to the
static ~10-model list. Extracted the scopes to an exported VERTEX_OAUTH_SCOPES
constant with a regression test so the discovery scope can't be silently dropped.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks, @artickc! 🙏 Good catch — without generative-language.retriever the SA token can't list the live catalog (403 ACCESS_TOKEN_SCOPE_INSUFFICIENT) and discovery silently falls back to the static ~10-model list. The extra scope is harmless for execution (cloud-platform stays). I extracted the scopes to an exported VERTEX_OAUTH_SCOPES constant + added a regression test so the discovery scope can't be dropped silently (17/17 vertex tests green). Merging into release/v3.8.26. 🚀

@diegosouzapw
diegosouzapw merged commit bb45ddf into cheaper-inference:release/v3.8.26 Jun 15, 2026
2 checks passed
@diegosouzapw diegosouzapw mentioned this pull request Jun 16, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants