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
fix: added _options to topOptions parameters.context.google check #148
Conversation
…options is not present.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
src/apirequest.ts
Outdated
@@ -74,7 +74,7 @@ async function createAPIRequestAsync<T>(parameters: APIRequestParams) { | |||
// Create a new params object so it can no longer be modified from outside | |||
// code Also support global and per-client params, but allow them to be | |||
// overriden per-request | |||
const topOptions = parameters.context.google | |||
const topOptions = parameters.context.google._options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Could you add a double layer of protection here?
const topOptions = parameters.context.google._options | |
const topOptions = (parameters.context.google && parameters.context.google._options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you also want to validate params. as so:
const topOptions = (parameters.context.google && parameters.context.google._options && parameters.context.google._options.params)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's strictly required here. To be honest I'm surprised there are situations where any of these are null/undefined, but it doesn't hurt to be careful :)
done, thank you for the prompt response! |
@giorod3 I think you just need to run |
@bcoe we are using this in js. I do not have the command |
If _options is not present in the parameters.context.google object then line 78 breaks on getting params from undefined.