{"record":{"id":"377852b7e6c29a4b","repo":"continuedev/continue","slug":"failed-to-load-credentials-for-vertex-ai-e-mess-377852","errorCode":null,"errorMessage":"Failed to load credentials for Vertex AI: ${e.message}","messagePattern":"Failed to load credentials for Vertex AI: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/VertexAI.ts","lineNumber":126,"sourceCode":"          jsonClient.scopes = [VertexAIApi.AUTH_SCOPES];\n        } else {\n          throw new Error(\"VertexAI: keyJson must be a valid JWT\");\n        }\n        this.clientPromise = Promise.resolve(jsonClient);\n      } catch (e) {\n        throw new Error(\"VertexAI: Failed to parse keyJson\");\n      }\n    } else if (keyFile) {\n      if (typeof keyFile !== \"string\") {\n        throw new Error(\"VertexAI: keyFile must be a string\");\n      }\n      this.clientPromise = new GoogleAuth({\n        scopes: VertexAIApi.AUTH_SCOPES,\n        keyFile,\n      })\n        .getClient()\n        .catch((e: Error) => {\n          console.warn(\n            `Failed to load credentials for Vertex AI: ${e.message}`,\n          );\n        });\n    } else if (!apiKey) {\n      // Application Default Credentials\n      this.clientPromise = new GoogleAuth({\n        scopes: VertexAIApi.AUTH_SCOPES,\n      })\n        .getClient()\n        .catch((e: Error) => {\n          console.warn(\n            `Failed to load credentials for Vertex AI: ${e.message}`,\n          );\n        });\n    }\n  }\n\n  private getApiBase(): string {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/VertexAI.ts#L108-L144","documentation":"VertexAI setupAuthentication, when a service account keyFile is configured, wraps GoogleAuth.getClient() and catches failures. On error it only logs this warning — clientPromise then resolves to undefined instead of rejecting, so the failure surfaces later as an opaque undefined-client error when a request is attempted.","triggerScenarios":"Configuring GOOGLE_APPLICATION_CREDENTIALS / a keyFile path that does not exist, is invalid JSON, lacks the right scopes, or the service account has no Vertex AI access; then constructing the VertexAIApi class.","commonSituations":"Wrong key file path in containers/CI, exporting a Workspace (not service account) JSON, key from a different GCP project, or missing Vertex AI API enablement.","solutions":["Verify the key file path exists and is a valid service-account JSON: `cat $GOOGLE_APPLICATION_CREDENTIALS | jq .type` should print service_account","Ensure the service account has roles/aiplatform.user and the Vertex AI API is enabled in the project","Confirm project/region config matches the key's project","Prefer Application Default Credentials (`gcloud auth application-default login`) when no keyFile is needed"],"exampleFix":"# before\nGOOGLE_APPLICATION_CREDENTIALS=/wrong/path/key.json\n\n# after\nGOOGLE_APPLICATION_CREDENTIALS=/secrets/valid-sa-key.json\n# validate:\ngcloud auth application-default print-access-token","handlingStrategy":"validation","validationCode":"const key = JSON.parse(await fs.readFile(keyFile, \"utf8\"));\nif (key.type !== \"service_account\") throw new Error(\"Not a service account key\");","typeGuard":"const isServiceAccountKey = (k: any): boolean =>\n  k?.type === \"service_account\" && !!k.client_email && !!k.private_key;","tryCatchPattern":"try {\n  await vertexApi.clientPromise;\n} catch (e) {\n  throw new Error(`Vertex AI auth failed: ${e.message}`);\n}","preventionTips":["Validate key file existence and JSON shape before constructing the client","Ensure the service account has aiplatform.user role","Note clientPromise may resolve undefined on auth failure — await and check it early"],"tags":["vertexai","gcp","authentication","service-account","credentials"],"backgroundTag":"gcp-credentials-load-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}