Description
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
A screenshot that you have tested with "Try this API".
It's the GCE internal metadata service.
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://gist.github.com/ernestoalejo/4e998384aed6f075277569c687bdc6d8
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
I started to receive an unexpected error when initializing a storage client. The client calls the metadata server to retrieve the application default credentials but one of the calls is to universe_domain which doesn't returns any Metadata-Flavor header at all.
The full stacktrace:
Error: Invalid response from metadata service: incorrect Metadata-Flavor header.
at metadataAccessor (/app/node_modules/.pnpm/[email protected]/node_modules/gcp-metadata/build/src/index.js:120:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async GoogleAuth.getUniverseDomainFromMetadataServer (/app/node_modules/.pnpm/[email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:169:30)
at async GoogleAuth.getApplicationDefaultAsync (/app/node_modules/.pnpm/[email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:266:21)
at async GoogleAuth.getClient (/app/node_modules/.pnpm/[email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:695:17)
at async GoogleAuth.authorizeRequest (/app/node_modules/.pnpm/[email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:736:24)
at async Promise.all (index 1)
at async prepareRequest (file:///app/node_modules/.pnpm/@[email protected]/node_modules/@google-cloud/storage/build/esm/src/nodejs-common/util.js:463:61)
I can't update the library version, is a third party software application which is not under our control.
When I curl the endpoint manually from the machine it doesn't return the header. In fact it accepts any header in the request or even no header at all and never returns its value like other endpoints:
curl -v -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/universe/universe_domain
* Host metadata.google.internal:80 was resolved.
* IPv6: (none)
* IPv4: 169.254.169.254
* Trying 169.254.169.254:80...
* Connected to metadata.google.internal (169.254.169.254) port 80
> GET /computeMetadata/v1/universe/universe_domain HTTP/1.1
> Host: metadata.google.internal
> User-Agent: curl/8.5.0
> Accept: */*
> Metadata-Flavor: Google
>
< HTTP/1.1 200 OK
< Content-Type: application/text
< ETag: 23d0ca25faab0f19
< Date: Mon, 10 Mar 2025 15:23:31 GMT
< Server: Metadata Server for VM
< Content-Length: 14
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
<
* Connection #0 to host metadata.google.internal left intact
googleapis.com
A clear and concise description of what the bug is, and what you expected to happen.
I know 9.7.0 is not the latest version of this library, but it's a third party software and I would totally expect the metadata server to keep working in GCE for existing software. Also it's not too old and I would expect a recent version of this library to keep working.
A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
The issue is with internal universe_domain call and the metadata service, there isn't public information to reference.