{"record":{"id":"7f19fcad3e463c9b","repo":"google-gemini/gemini-cli","slug":"invalid-google-cloud-project-id-projectid-t","errorCode":null,"errorMessage":"Invalid Google Cloud Project ID: \"${projectId}\". The GOOGLE_CLOUD_PROJECT (or GOOGLE_CLOUD_PROJECT_ID) environment variable must be set to your string-based Project ID (e.g., \"my-project-123\"), not your numeric Project Number. Please update your environment variables.","messagePattern":"Invalid Google Cloud Project ID: \"(.+?)\"\\. The GOOGLE_CLOUD_PROJECT \\(or GOOGLE_CLOUD_PROJECT_ID\\) environment variable must be set to your string-based Project ID \\(e\\.g\\., \"my-project-123\"\\), not your numeric Project Number\\. Please update your environment variables\\.","errorType":"validation","errorClass":"InvalidNumericProjectIdError","httpStatus":null,"severity":"error","filePath":"packages/core/src/code_assist/setup.ts","lineNumber":135,"sourceCode":" * @param httpOptions - Optional HTTP options\n * @returns The user's project ID, tier ID, and tier name\n * @throws {ValidationRequiredError} If account validation is required\n * @throws {ProjectIdRequiredError} If no project ID is available and required\n * @throws {ValidationCancelledError} If user cancels validation\n * @throws {ChangeAuthRequestedError} If user requests to change auth method\n */\nexport async function setupUser(\n  client: AuthClient,\n  config: Config,\n  httpOptions: HttpOptions = {},\n): Promise<UserData> {\n  const projectId =\n    process.env['GOOGLE_CLOUD_PROJECT'] ||\n    process.env['GOOGLE_CLOUD_PROJECT_ID'] ||\n    undefined;\n\n  if (projectId && /^\\d+$/.test(projectId)) {\n    throw new InvalidNumericProjectIdError(projectId);\n  }\n\n  const projectCache = userDataCache.getOrCreate(client, () =>\n    createCache<string | undefined, Promise<UserData>>({\n      storage: 'map',\n      defaultTtl: 30000, // 30 seconds\n    }),\n  );\n\n  return projectCache.getOrCreate(projectId, () =>\n    _doSetupUser(client, projectId, config, httpOptions),\n  );\n}\n\n/**\n * Internal implementation of the user setup logic.\n */\nasync function _doSetupUser(","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/code_assist/setup.ts#L117-L153","documentation":"Thrown as InvalidNumericProjectIdError by setupUser() when the GOOGLE_CLOUD_PROJECT or GOOGLE_CLOUD_PROJECT_ID environment variable contains a purely numeric string (matches /^\\d+$/). Google Cloud project IDs are string-based (e.g., 'my-project-123'); project numbers are numeric and are a different identifier. The Code Assist API requires the string project ID, so a numeric value is always wrong. The error includes the offending value and instructs the user to update their environment.","triggerScenarios":"setupUser() reads GOOGLE_CLOUD_PROJECT (or GOOGLE_CLOUD_PROJECT_ID) from process.env, finds it matches /^\\d+$/, and throws InvalidNumericProjectIdError. For example, setting export GOOGLE_CLOUD_PROJECT=123456789012 (a project number) triggers this.","commonSituations":"User copied the Project Number from the Google Cloud Console instead of the Project ID; automation scripts that inject the numeric project identifier; confusion between 'Project ID' (string) and 'Project Number' (integer) in GCP console; terraform/infrastructure scripts outputting the number instead of the ID.","solutions":["Find your Project ID in the Google Cloud Console (it looks like 'my-project-123', not a pure number) and set export GOOGLE_CLOUD_PROJECT=my-project-123.","Run 'gcloud projects list' to see both the ID and number; copy the ID column.","Update any automation/CI scripts to use the string project ID, not the numeric project number.","Unset the env var to let gcloud's default project config apply: unset GOOGLE_CLOUD_PROJECT."],"exampleFix":"# before — project number (wrong)\nexport GOOGLE_CLOUD_PROJECT=123456789012\n\n# after — project ID (correct)\nexport GOOGLE_CLOUD_PROJECT=my-project-123\n\n# Find your project ID\ngcloud projects list --format='table(projectId, projectNumber, name)'","handlingStrategy":"validation","validationCode":"// Validate project ID format before using it\nfunction isValidProjectId(id: string): boolean {\n  // Project IDs are string-based, not purely numeric\n  return !/^\\d+$/.test(id) && /^[a-z][a-z0-9-]{4,28}[a-z0-9]$/.test(id);\n}\n\nconst projectId = process.env['GOOGLE_CLOUD_PROJECT'];\nif (projectId && !isValidProjectId(projectId)) {\n  throw new Error(\n    `GOOGLE_CLOUD_PROJECT='${projectId}' looks like a Project Number. Use the string Project ID instead.`\n  );\n}","typeGuard":"function isStringProjectId(id: string | undefined): id is string {\n  return typeof id === 'string' && id.length > 0 && !/^\\d+$/.test(id);\n}","tryCatchPattern":"try {\n  await setupUser(client, config, httpOptions);\n} catch (e) {\n  if (e instanceof InvalidNumericProjectIdError) {\n    console.error(\n      `GOOGLE_CLOUD_PROJECT is set to a numeric Project Number. ` +\n      `Find your Project ID with 'gcloud projects list' and set it instead.`\n    );\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Always use the string Project ID from gcloud projects list, not the Project Number.","Validate the project ID format in CI scripts before launching the CLI.","Educate users on the difference between Project ID and Project Number.","Add a shell startup check that warns if GOOGLE_CLOUD_PROJECT is numeric."],"tags":["code-assist","project-id","environment","configuration","gcp"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}