question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cloudresourcemanager.project.getIamPolicy recently started throwing 'Missing required parameter "body"'

See original GitHub issue

Replicated in version 1.7.7, 1.7.8, and 1.7.9 on MacOS, and various flavors of linux with python 3.7

Prior to July 3rd, the following code worked, and returned the IAM policy for a given project:

from googleapiclient.discovery import build
service = build('cloudresourcemanager','v1')
req = service.projects().getIamPolicy(resource='my-project')
resp = req.execute()
print(resp)

Since then, our existing applications using that functionality started throwing an error that the required parameter body was missing. At first I thought google made a breaking change to the discovery document, but upon checking, the discovery doc does not require the body parameter. Then I started poking around and I see this library adds it as required here: https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/discovery.py#L494

All of the code related to this, that I noticed, is over 7 years old. So its unlikely that a change to the library broke anything. One thing that COULD explain the issue is a few lines below the line i linked above… IF the discovery document didn’t previously send a request field in the method description, this library would make the body optional. I have no way to determine if that actually happened, as I don’t have any older cached discovery documents for the cloudresourcemanager v1 API.

I realize what I’m reporting here isn’t a bug with this library, but something appears to have changed the behavior in this case (and potentially others) so I wanted to:

  • report it (so others can find it)
  • see if you have a way to determine what happened

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
busunkim96commented, Jul 16, 2019

Other folks were impacted by this change and reached out via the internal issue tracker.

After discussion with folks on the team, the recommendation was to pass an empty body and let the server do the validation. I will create a PR shortly.

1reaction
busunkim96commented, Jul 15, 2019

@jceresini A PR would most definitely be appreciated!

My only concern is that “OPTIONAL” is marked inside the string for description. I’m not sure if this is the standard way (across APIs), or if this was done one-off for cloud resource manager. I’ll look into that and get back to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method: projects.getIamPolicy | Resource Manager
Permission is denied if the policy or the resource does not exist. Authorization requires the Google IAM permission resourcemanager.projects.
Read more >
Params$Resource$Projects$Serviceaccounts$Getiampolicy
REQUIRED : The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
Read more >
GCP Create Project via Python - Stack Overflow
Sufficient scope is not added in the API. You need to add scope in your code.Try to add : googleapis.com/auth/cloud-platform. googleapis.
Read more >
Project - Google Developers
Lists Projects that the caller has the `resourcemanager.projects.get` ... getIamPolicy(resource=None, body=None, x__xgafv=None)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found