genkit icon indicating copy to clipboard operation
genkit copied to clipboard

JS Vertex AI plugin does not read GOOGLE_CLOUD_LOCATION, unlike Go and Python

Open cabljac opened this issue 2 months ago • 3 comments

js/plugins/google-genai/src/vertexai/utils.ts has no occurrence of GOOGLE_CLOUD_LOCATION. Location comes from GCLOUD_LOCATION only:

  • multi-regional: options?.location || process.env.GCLOUD_LOCATION, throws when unset (utils.ts:255-259)
  • regional: same, defaulting to us-central1 (utils.ts:289-290)

Go uses firstEnv("GOOGLE_CLOUD_LOCATION", "GOOGLE_CLOUD_REGION") (go/plugins/googlegenai/googlegenai.go). Python falls back to GOOGLE_CLOUD_LOCATION or GCLOUD_LOCATION (py/packages/genkit-google-genai/src/genkit_google_genai/google.py).

Vertex AI Agent Engine injects GOOGLE_CLOUD_LOCATION, not GCLOUD_LOCATION. Project resolution survives on other fallbacks; location does not.

Unreconciled: the multi-regional throw looks swallowed (utils.ts:126-128) before regional is tried, which defaults, so I would expect a silent wrong region. We saw a throw on first request. No minimal repro yet, so trust the env var gap over my account of the failure mode.

Fix: add GOOGLE_CLOUD_LOCATION to the fallback chain in both functions.

cabljac avatar Sep 18 '26 13:09 cabljac

Hi! I would like to work on this issue. My plan: add GOOGLE_CLOUD_LOCATION to the fallback chain in both functions in js/plugins/google-genai/src/vertexai/utils.ts (multi-regional and regional), mirroring the Go/Python behavior, plus a unit test. One question before I start: should the chain also include GOOGLE_CLOUD_REGION like the Go plugin (firstEnv GOOGLE_CLOUD_LOCATION, GOOGLE_CLOUD_REGION), or keep it to GOOGLE_CLOUD_LOCATION + GCLOUD_LOCATION? Thanks!

aslamalkarywk7 avatar Sep 18 '26 22:09 aslamalkarywk7

Opened PR #6386 with the fix (fallback chain + updated error messages + 3 unit tests). Still happy to add GOOGLE_CLOUD_REGION too if you prefer Go parity. Google CLA is already signed on my account.

aslamalkarywk7 avatar Sep 18 '26 22:09 aslamalkarywk7

Hi! It looks like the earlier attempt (#6386) was closed without merging. If nobody is working on this anymore, I'd be happy to pick it up and send a fix with tests.

AndresDvst avatar Dec 02 '26 11:12 AndresDvst