anomalyco/opencode★ 203,745

fix: add GOOGLE_VERTEX_LOCATION env var support for Vertex AI

Mergedopened · merged · #16922

About anomalyco/opencode

The open source coding agent.

The change

The @ai-sdk/google-vertex package expects GOOGLE_VERTEX_LOCATION as the standard environment variable for location. Added this env var to the fallback chain in both googleVertexVars() and CUSTOM_LOADERS. Fixes #15838 Issue for this PR Closes #15838 Type of change • ✓ Bug fix • ○ New feature • ○ Refactor / code improvement • ○ Documentation What does this PR do? Problem: When using Google Vertex AI models (e.g., gemini-3.1-pro-preview), users get an AI_LoadSettingError even after setting the GOOGLE_VERTEX_LOCATION environment variable. Root Cause: The code in packages/opencode/src/provider/provider.ts was only checking GOOGLE_CLOUD_LOCATION and VERTEX_LOCATION environment variables, but the @ai-sdk/google-vertex package expects GOOGLE_VERTEX_LOCATION as the standard environment variable name (confirmed by reading the package's TypeScript definitions and source code in node_modules). Fix: Added GOOGLE_VERTEX_LOCATION to the environment variable fallback chain in two locations: 1. googleVertexVars() function (line ~69) 2. CUSTOM_LOADERS["google-vertex"] async function (line ~395) Why it works: The @ai-sdk/google-vertex package uses loadSetting() with environmentVariableName: "GOOGLE_VERTEX_LOCATION". By checking this environment variable in opencode's provider initialization, the value is now properly passed through to the underlying SDK. How did you verify your code works? 1. Read the @ai-sdk/google-vertex package source code in node_modules to confirm the expected environment variable 2. Ran existing provider tests: bun test test/provider/provider.test.ts - 70 tests passed 3. Ran transform tests: bun test test/provider/transform.test.ts - 107 tests passed 4. Verified the fix with git diff showing the minimal change Screenshots / recordings N/A - backend fix Checklist • ✓ I have tested my changes locally • ✓ I have not included unrelated changes in this PR

Referenced issues