Skip to content

ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account #3533

Closed
@danielnorberg

Description

@danielnorberg

When running on a GCE host, ServiceOptions.getDefaultProjectId() incorrectly returns the project id from the GCE metadata server instead of defaulting to the project ID specified in the JSON credentials file pointed by the GOOGLE_APPLICATION_CREDENTIALS environment variable.

This seems to be due to getAppEngineProjectId() returning a project id even when running outside GAE, causing getDefaultProjectId() to not call getServiceAccountProjectId().

This seems to have been introduced in #3413 and resulted in the behavior changing from google-cloud-core 1.3.0 to 1.4.0.

Documentation:

Repro: https://github.com/danielnorberg/google-cloud-java-default-project-bug-repro

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions