-
Notifications
You must be signed in to change notification settings - Fork 373
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
file.acl.get
malformed request if entity
is not provided
#2159
Comments
Thank you for opening an issue @theGOTOguy. I am assuming you are attempting this from a JavaScript application and not TypeScript? When I attempt this in a TypeScript I'm not even able to compile due to the following:
Additionally, in looking at the JSON API docs this is a documented required field. We generally shy away from adding additional error checking on top of what the API returns. However, it does appear that the docs for ACL are missing from the client docs and I will look into the reason behind that. |
Yes, I am using JavaScript and not Typescript. I agree with you that the client is not the right place to do error checking for the API. In vanilla JavaScript, the client defaults a different value for entity depending on whether other options are included or not which is certainly less desirable than either setting it to a consistent default or failing the request entirely for missing a default field. |
Correcting what I said above, I did find the client docs, however they appear incorrectly labeling |
Do you have the stack trace of the error? I assumed this was something bubbling up from the API side, if not I can look at correcting it in the client. |
I agree that to make entity required would be an acceptable fix, but I wanted to add a few concerns you might want to consider before considering this closed.
ben@anteater:~$ node
Welcome to Node.js v17.2.0.
Type ".help" for more information.
> '/' + encodeURIComponent(undefined)
'/undefined' What's happening is that when entity is not provided, if any other option is provided, then we hit this line and the default value of entity provided by your client becomes |
To clarify a bit further Under the current code if a user does not supply the entity argument or supplies it incorrectly the server returns a The documentation does say that supplying no arguments retrieves all acls but stops short of saying that it is essentially 2 different API calls without parameters vs with parameters. This |
Environment details
@google-cloud/storage
version: 6.9.0Steps to reproduce
The reason for this is here. If
entity
is not provided but any other option is, then our path is/undefined
. On the other hand, if no options at all are provided,entity
effectively defaults to''
. The issue can straightforwardly be worked around by providing the option{entity: ''}
.I propose one of two solutions:
entity
to empty string. This effectively makesentity
not a required field.entity
as a required field. Failfile.acl.get(...)
ifentity
is not provided. Document that users wishing to retrieve all ACLs should pass{entity: ''}
.The text was updated successfully, but these errors were encountered: