{"record":{"id":"d19669c488a78c0c","repo":"continuedev/continue","slug":"region-and-projectid-are-required-for-vertexai-wh-d19669","errorCode":null,"errorMessage":"region and projectId are required for VertexAI (when not using express/apiKey mode)","messagePattern":"region and projectId are required for VertexAI \\(when not using express/apiKey mode\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/VertexAI.ts","lineNumber":87,"sourceCode":"    }\n  }\n\n  private setupAuthentication(): void {\n    const { apiKey, env } = this.config;\n    const { region, projectId, keyFile, keyJson } = env || {};\n\n    // Validate authentication configuration\n    if (apiKey) {\n      // Express mode validation\n      if (region || projectId || keyFile || keyJson) {\n        throw new Error(\n          \"VertexAI in express mode (apiKey only) cannot be configured with region, projectId, keyFile, or keyJson\",\n        );\n      }\n    } else {\n      // Standard mode validation\n      if (!region || !projectId) {\n        throw new Error(\n          \"region and projectId are required for VertexAI (when not using express/apiKey mode)\",\n        );\n      }\n      if (keyFile && keyJson) {\n        throw new Error(\n          \"VertexAI credentials can be configured with either keyFile or keyJson but not both\",\n        );\n      }\n    }\n\n    // Set up authentication client\n    if (keyJson) {\n      try {\n        const parsed = JSON.parse(keyJson);\n        if (!parsed?.private_key) {\n          throw new Error(\"VertexAI: keyJson must contain a valid private key\");\n        }\n        parsed.private_key = parsed.private_key.replace(/\\\\n/g, \"\\n\");","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/VertexAI.ts#L69-L105","documentation":"VertexAI standard mode (no apiKey) requires both region and projectId in setupAuthentication; missing either throws this error from the constructor before any request is made.","triggerScenarios":"Constructing VertexAIApi without apiKey and with env lacking region or projectId (e.g. only keyJson provided).","commonSituations":"Service-account setups copied from Google examples that omit the region; env var names not matching what the adapter reads; assuming projectId is inferred from the service account (it is not).","solutions":["Set both region (e.g. us-central1) and projectId in the Vertex env config","Or switch to express mode by supplying apiKey only","Verify the env object actually reaches the adapter (not just process.env)"],"exampleFix":"// before\nnew VertexAIApi({ env: { keyJson } })\n// after\nnew VertexAIApi({ env: { region: 'us-central1', projectId: 'my-project', keyJson } })","handlingStrategy":"validation","validationCode":"if (!cfg.apiKey && (!cfg.env?.region || !cfg.env?.projectId)) throw new Error('region and projectId required for standard mode');","typeGuard":"const isValidStandardConfig = (c: VertexConfig) => !c.apiKey ? !!(c.env?.region && c.env?.projectId) : true;","tryCatchPattern":"try { new VertexAIApi(cfg); } catch (e) { if (e.message.includes('region and projectId are required')) throw new ConfigError('Set VERTEX region+projectId or use apiKey'); throw e; }","preventionTips":["Always pair region and projectId in standard mode","Fail fast on config validation at app boot"],"tags":["vertexai","config","missing-parameter","authentication"],"backgroundTag":"missing-required-parameter","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}