{"record":{"id":"1258ae89a7a173eb","repo":"mem0ai/mem0","slug":"vertex-ai-could-not-determine-a-google-cloud-proje","errorCode":null,"errorMessage":"Vertex AI could not determine a Google Cloud project ID. Set googleProjectId in config, one of the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, or configure Application Default Credentials: ${err.message}","messagePattern":"Vertex AI could not determine a Google Cloud project ID\\. Set googleProjectId in config, one of the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, or configure Application Default Credentials: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/embeddings/vertexai.ts","lineNumber":121,"sourceCode":"      });\n    }\n    await this.initPromise;\n  }\n\n  private async createClient(): Promise<void> {\n    const aiplatform: AIPlatform = await loadPeer(\n      \"@google-cloud/aiplatform\",\n      \"Vertex AI embedding provider\",\n      () => import(\"@google-cloud/aiplatform\"),\n    );\n\n    const client = new aiplatform.PredictionServiceClient(this.clientOptions);\n\n    if (!this.projectId) {\n      try {\n        this.projectId = await client.getProjectId();\n      } catch (err) {\n        throw new Error(\n          \"Vertex AI could not determine a Google Cloud project ID. Set googleProjectId in config, \" +\n            \"one of the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, or configure \" +\n            \"Application Default Credentials: \" +\n            (err as Error).message,\n        );\n      }\n    }\n\n    this.client = client;\n    this.helpers = aiplatform.helpers;\n  }\n\n  private endpoint(): string {\n    return `projects/${this.projectId}/locations/${this.location}/publishers/google/models/${this.model}`;\n  }\n\n  private formatInstance(text: string, taskType: string) {\n    // task_type must live on the instance (snake_case), not in `parameters`.","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/embeddings/vertexai.ts#L103-L139","documentation":"VertexAIEmbedder resolves the GCP project in three steps: explicit config.googleProjectId, the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, then Application Default Credentials via client.getProjectId(). This error means all of those failed, and the appended err.message explains why ADC resolution failed (e.g. no credentials, no quota project).","triggerScenarios":"Running outside GCP with no gcloud auth application-default login; GOOGLE_APPLICATION_CREDENTIALS pointing to a missing file; a service account whose metadata is reachable but has no resolvable project; none of the three env vars set and googleProjectId omitted from config.","commonSituations":"Local development after cloning a project that worked in GCE/Cloud Run; CI runner without ADC setup; the ADC file was revoked or deleted; workload identity not available in the target namespace.","solutions":["Pass googleProjectId explicitly in the embedder config: new VertexAIEmbedder({ googleProjectId: 'my-project', ... })","Set one of GCP_PROJECT_ID, GOOGLE_CLOUD_PROJECT, or GCLOUD_PROJECT in the environment","For local dev, run: gcloud auth application-default login","For service accounts, set GOOGLE_APPLICATION_CREDENTIALS to the key file path and ensure the SA belongs to a project","Read the trailing (err as Error).message: it names the exact ADC failure"],"exampleFix":"// before\nconst embedder = new VertexAIEmbedder({}); // relies on ADC which is absent\n\n// after\nconst embedder = new VertexAIEmbedder({\n  googleProjectId: process.env.GCP_PROJECT_ID!,\n  googleServiceAccountJson: process.env.GCP_SA_JSON,\n});","handlingStrategy":"validation","validationCode":"const projectId = cfg.googleProjectId\n  ?? process.env.GCP_PROJECT_ID\n  ?? process.env.GOOGLE_CLOUD_PROJECT\n  ?? process.env.GCLOUD_PROJECT;\nif (!projectId && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {\n  throw new Error(\"No GCP project: set googleProjectId, a GCP_PROJECT env var, or run gcloud auth application-default login\");\n}","typeGuard":"function isProjectIdError(err: unknown): boolean {\n  return err instanceof Error && err.message.includes(\"could not determine a Google Cloud project ID\");\n}","tryCatchPattern":"try {\n  await embedder.embed(text);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"could not determine a Google Cloud project ID\")) {\n    throw new Error(\"Vertex config incomplete: pass googleProjectId explicitly\");\n  }\n  throw err;\n}","preventionTips":["Always pass googleProjectId explicitly in non-GCP environments","Verify ADC once at startup: a quick client.getProjectId() health check","Document required env vars (GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT) in deployment manifests"],"tags":["vertexai","gcp","project-id","credentials","configuration","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}