Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getIamPolicy for KMS KeyManagementServiceClient is erroring with Syntax Error: Unexpected token < in JSON at position 0 , when using fallback REST #1462

Open
sirohiwebdev opened this issue Jun 21, 2023 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@sirohiwebdev
Copy link

sirohiwebdev commented Jun 21, 2023

  1. Is this a client library issue or a product issue?
    Yes it is a client library issue, the definition for getIamPolicy method in iam_services.json mentions POST call whether the actual call is GET

  2. Did someone already solve this?
    Could not find any solution or issues created for the same.

  3. Do you have a support contract?
    No

Environment details

  • OS: WSL 2Ubuntu 20.04.4 LTS
  • Node.js version: 18.14.2
  • npm version: 9.5.0
  • google-gax version: 3.6.0

Steps to reproduce

  1. Call the following method for KMS
import * as kms from "@google-cloud/kms";
import { google } from "@google-cloud/iap/build/protos/protos";
import GetIamPolicyRequest = google.iam.v1.GetIamPolicyRequest;

const keyManagementServiceClient = new kms.KeyManagementServiceClient({
  credentials: {
    client_email: "user@project-id.iam.gserviceaccount.com",
    private_key:"very-long-private-key",
  },
  projectId: "project-id",
  fallback: "rest",
});

const req = new GetIamPolicyRequest({
  resource: "projects/project-id/locations/global/keyRings/qflow",
});
keyManagementServiceClient
  .getIamPolicy(req)
  .then(console.log)
  .catch(console.error);
  1. It is using the POST method to hit the API
    Output (Before)
    image

  2. After making a change to the following [file ](https://github.com/googleapis/gax-
    nodejs/blob/main/protos/iam_service.json#L43,L49)and replacing post with get issue seems to be resolved.

Changes

image

Output (After)
image

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@sirohiwebdev sirohiwebdev added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 21, 2023
@sirohiwebdev sirohiwebdev changed the title getIamPolicy for KMS KeyManagementServiceClient is erroring with Syntax Error: Unexpected token < in JSON at position 0 getIamPolicy for KMS KeyManagementServiceClient is erroring with Syntax Error: Unexpected token < in JSON at position 0 , when using fallback REST Jun 21, 2023
@sirohiwebdev
Copy link
Author

Hi @alexander-fenster
Eagerly waiting for your response.

@alexander-fenster alexander-fenster removed their assignment May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants