Title: ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account · Issue #3533 · googleapis/google-cloud-java · GitHub
Open Graph Title: ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account · Issue #3533 · googleapis/google-cloud-java
X Title: ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account · Issue #3533 · googleapis/google-cloud-java
Description: 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_APPLICA...
Open Graph Description: 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 creden...
X Description: 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 creden...
Opengraph URL: https://github.com/googleapis/google-cloud-java/issues/3533
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account","articleBody":"When running on a GCE host, [`ServiceOptions.getDefaultProjectId()`](https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L332) 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.\r\n\r\nThis seems to be due to [`getAppEngineProjectId()`](https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L339) returning a project id even when running outside GAE, causing `getDefaultProjectId()` to not call `getServiceAccountProjectId()`.\r\n\r\nThis seems to have been introduced in https://github.com/GoogleCloudPlatform/google-cloud-java/pull/3413 and resulted in the behavior changing from `google-cloud-core` `1.3.0` to `1.4.0`.\r\n\r\nDocumentation: \r\n* https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id\r\n* https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L321\r\n\r\nRepro: https://github.com/danielnorberg/google-cloud-java-default-project-bug-repro","author":{"url":"https://github.com/danielnorberg","@type":"Person","name":"danielnorberg"},"datePublished":"2018-08-06T14:26:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/3533/google-cloud-java/issues/3533"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:128f8dd4-393c-4f3b-fb0a-f6172b4625cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEEA:30AD7C:1CD78CA:28830A3:6A4CC850 |
| html-safe-nonce | cb6396a7563021e680f56246c8b4f043e39dd74aa0bea9087a2af1cac11acdfe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUVBOjMwQUQ3QzoxQ0Q3OENBOjI4ODMwQTM6NkE0Q0M4NTAiLCJ2aXNpdG9yX2lkIjoiNDA0NjYzNzU0NTc2ODY2NzIxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8973a72cbefe4f26f9ee185d81250abe72247374c66a857bc6f3c6ae943ce6eb |
| hovercard-subject-tag | issue:347946926 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-java/3533/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c2e2cc23256291beb9026044b5a777ad872b3a2468ce68a01d726fe31d9c7cd/googleapis/google-cloud-java/issues/3533 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c2e2cc23256291beb9026044b5a777ad872b3a2468ce68a01d726fe31d9c7cd/googleapis/google-cloud-java/issues/3533 |
| og:image:alt | 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 creden... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danielnorberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-java git https://github.com/googleapis/google-cloud-java.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 26181278 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26181278 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d0da0eb92994395299ed4450bf67b0373005be36 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width