-
Notifications
You must be signed in to change notification settings - Fork 406
Description
Steps to Reproduce:
Create a Node.js project that depends on google‑gax 5.0.1‑rc.0 (directly or indirectly via a higher‑level API client such as the Google Meet API client).
Configure authentication using domain‑wide delegation (i.e. initialize an authentication client with a subject field to impersonate a user).
Instantiate the API client (e.g. the Google Meet API client) that uses google‑gax under the hood.
Make an API call that triggers the authentication flow (for example, creating a new Meet space).
Observe the error:
Error: 2 UNKNOWN: Getting metadata from plugin failed with error: headers.forEach is not a function
Code
import { SpacesServiceClient, protos } from '@google-apps/meet';
import { google } from 'googleapis';
// Minimal auth client using domain-wide delegation via a service account key
async function getAuthClient(subject) {
const auth = new google.auth.GoogleAuth({
clientOptions: { subject },
keyFilename: 'path/to/service-account.json', // Replace with your key file path
scopes: [
'https://www.googleapis.com/auth/meetings.space.readonly',
'https://www.googleapis.com/auth/meetings.space.created',
],
});
return auth.getClient();
}
async function createMeet() {
const subject = '[email protected]'; // Replace with an account set up for delegation
const authClient = await getAuthClient(subject);
const client = new SpacesServiceClient({ authClient });
const config = {
accessType: protos.google.apps.meet.v2.SpaceConfig.AccessType.OPEN,
entryPointAccess: protos.google.apps.meet.v2.SpaceConfig.EntryPointAccess.ALL,
};
try {
const [response] = await client.createSpace({ space: { config } });
console.log('Created space:', response);
} catch (err) {
console.error(err);
}
}
createMeet();Description
I'm not using Google-gax directly but only the Google Meet API and Google auth library, but the bug seems to be here.
It seems that google‑gax version 5.0.1‑rc.0 (which upgrades to google‑auth‑library v10) in a project that utilizes domain‑wide delegation (impersonation) for Google Workspace APIs (e.g. the Google Meet API), a runtime error is thrown during authentication:
Error: 2 UNKNOWN: Getting metadata from plugin failed with error: headers.forEach is not a function
It appears that during the authentication flow, the auth client returns metadata (headers) in a format that does not support iteration (i.e. it lacks a forEach method), which is required by grpc‑js. This suggests a compatibility issue between google‑auth‑library v10 and how google‑gax (and by extension, grpc‑js) processes authentication metadata.
More info
The authentication client should return metadata in a format compatible with grpc‑js (i.e. with a valid forEach method), and API calls should complete successfully.
Actual Behavior:
API calls fail with the above error, indicating that the headers object does not support the expected iteration.
Workarounds and Observations:
I downgraded to Google Meet v0.4.0 and the problem disappeared. So the affected version are v0.5.0 and v0.6.0 which are using the v5-xx-RC of google-gax
The error likely arises from the new handling of metadata (headers) in google‑auth‑library v10 when used with gRPC through google‑gax.
Environment:
- Node.js: v22.14.0
- OS: Fedora ( but also on production in Google App Engine )
- Relevant Package Versions:
- google‑gax: 5.0.1‑rc.0
- google‑auth‑library: v10.x (default with this version of google‑gax)