{"record":{"id":"c9008dcde8bcd8ba","repo":"grpc/grpc-go","slug":"empty-destination-project-id","errorCode":null,"errorMessage":"empty destination project ID","messagePattern":"empty destination project ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/config.go","lineNumber":148,"sourceCode":"\t\t}\n\t\tcontent, err := os.ReadFile(f)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading observability configuration file %q: %v\", f, err)\n\t\t}\n\t\treturn unmarshalAndVerifyConfig(content)\n\t} else if envconfig.ObservabilityConfig != \"\" {\n\t\treturn unmarshalAndVerifyConfig([]byte(envconfig.ObservabilityConfig))\n\t}\n\t// If the ENV var doesn't exist, do nothing\n\treturn nil, nil\n}\n\nfunc ensureProjectIDInObservabilityConfig(ctx context.Context, config *config) error {\n\tif config.ProjectID == \"\" {\n\t\t// Try to fetch the GCP project id\n\t\tprojectID := fetchDefaultProjectID(ctx)\n\t\tif projectID == \"\" {\n\t\t\treturn fmt.Errorf(\"empty destination project ID\")\n\t\t}\n\t\tconfig.ProjectID = projectID\n\t}\n\treturn nil\n}\n\ntype clientRPCEvents struct {\n\t// Methods is a list of strings which can select a group of methods. By\n\t// default, the list is empty, matching no methods.\n\t//\n\t// The value of the method is in the form of <service>/<method>.\n\t//\n\t// \"*\" is accepted as a wildcard for:\n\t//    1. The method name. If the value is <service>/*, it matches all\n\t//    methods in the specified service.\n\t//    2. The whole value of the field which matches any <service>/<method>.\n\t//    It’s not supported when Exclude is true.\n\t//    3. The * wildcard cannot be used on the service name independently,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/gcp/observability/config.go#L130-L166","documentation":"ensureProjectIDInObservabilityConfig requires a destination GCP project to which logs/metrics/traces are exported. The config's project_id is empty and fetchDefaultProjectID also returned empty (no GOOGLE_CLOUD_PROJECT env var and the Application Default Credentials either failed to load or had no project_id). Without a project the exporters cannot be constructed, so initialization aborts.","triggerScenarios":"Running outside GCE/GKE without GOOGLE_CLOUD_PROJECT set and without GOOGLE_APPLICATION_CREDENTIALS pointing to a service-account JSON that contains a project_id; running locally with aADC that lacks project metadata (e.g. external account credentials).","commonSituations":"Local dev without setting GOOGLE_CLOUD_PROJECT; CI runner that uses a token-based credential without a project; service account key JSON stripped of its project_id field.","solutions":["Set the GOOGLE_CLOUD_PROJECT env var to your GCP project ID before starting the process.","Set \"project_id\" in the observability config JSON directly so the lookup is skipped.","Provide Application Default Credentials whose JSON includes a project_id (gcloud auth application-default login with a SA key that has the project)."],"exampleFix":"// before\nexport GOOGLE_APPLICATION_CREDENTIALS=/svc/sa.json\n# (sa.json has no project_id, no GOOGLE_CLOUD_PROJECT)\n\n// after\nexport GOOGLE_CLOUD_PROJECT=my-gcp-project\nexport GOOGLE_APPLICATION_CREDENTIALS=/svc/sa.json","handlingStrategy":"validation","validationCode":"func ensureProjectID(cfg *config) error {\n    if cfg.ProjectID != \"\" { return nil }\n    if os.Getenv(\"GOOGLE_CLOUD_PROJECT\") != \"\" { return nil }\n    return errors.New(\"no project id: set config.project_id or GOOGLE_CLOUD_PROJECT or provide ADC with a project_id\")\n}","typeGuard":null,"tryCatchPattern":"if err := ensureProjectIDInObservabilityConfig(ctx, cfg); err != nil {\n    return fmt.Errorf(\"observability: %w\", err)\n}","preventionTips":["Always set GOOGLE_CLOUD_PROJECT in non-GCE environments.","Populate project_id explicitly in the config JSON for portability.","Ensure the ADC JSON includes project_id (some external-account creds do not)."],"tags":["grpc","observability","gcp","project-id","auth","config"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}