forwardemail / forwardemail/supertest
[fix] Supertest - GCP Error - 2 UNKNOWN: Getting metadata from plugin failed with error: Unexpected Gaxios Error
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the bug
**Node.js version:** v25.1.0
**OS version:** macOS Tahoe 26.1
**Description:** Getting an error "2 UNKNOWN: Getting metadata from plugin failed with error: Unexpected Gaxios Error" while trying to retrieve the GCP secret.
## Actual behavior
Getting an error "2 UNKNOWN: Getting metadata from plugin failed with error: Unexpected Gaxios Error" while trying to retrieve the GCP secret.
## Expected behavior
Should be able to retrieve the GCP secrets successfully without any errors.
## Code to reproduce
import request, { Response } from "supertest";
describe("Endpoints", () => {
let authToken: string;
beforeAll(async () => {
authToken = await getAccessToken(BASE_URL);
});
export async function getAccessToken(baseUrl: string): Promise {
const username = await getSecretValue("");
const reqBody = "";
request(baseUrl)
.post("/auth/token")
.auth(username)
.set("Content-Type", "application/x-www-form-urlencoded")
.send(reqBody);
}
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
import { gcp_secret_project_name } from '../../config';
const client = new SecretManagerServiceClient();
export async function getSecretValue(secretId: string): Promise {
const [version] = await client.accessSecretVersion({
name: `projects/${gcp_secret_project_name}/secrets/${secretId}/versions/latest`,
});
return version.payload?.data?.toString() || '';
}
Failing in this line of code: await client.accessSecretVersion({
name: `projects/${gcp_secret_project_name}/secrets/${secretId}/versions/latest`,
});
with:
`2 UNKNOWN: Getting metadata from plugin failed with error: Unexpected Gaxios Error
`
## Checklist
- [X] I have searched through GitHub issues for similar issues.
- [X] I have completely read through the README and documentation.
- [X] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Contributor guide
Assessment
This issue has not been assessed yet.