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

fix: added _options to topOptions parameters.context.google check #148

Merged
merged 6 commits into from Jun 28, 2019

Conversation

giorod3
Copy link
Contributor

@giorod3 giorod3 commented Jun 25, 2019

If _options is not present in the parameters.context.google object then line 78 breaks on getting params from undefined.

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Jun 25, 2019
@giorod3
Copy link
Contributor Author

giorod3 commented Jun 25, 2019

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jun 25, 2019
@@ -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
Copy link
Contributor

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?

Suggested change
const topOptions = parameters.context.google._options
const topOptions = (parameters.context.google && parameters.context.google._options)

Copy link
Contributor Author

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)

Copy link
Contributor

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 :)

@giorod3
Copy link
Contributor Author

giorod3 commented Jun 25, 2019

done, thank you for the prompt response!

@JustinBeckwith JustinBeckwith added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 25, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 25, 2019
@bcoe
Copy link
Contributor

bcoe commented Jun 27, 2019

@giorod3 I think you just need to run npm run fix, you appear to be having some TypeScript linting issues, hence the breaking builds.

@giorod3
Copy link
Contributor Author

giorod3 commented Jun 28, 2019

@giorod3 I think you just need to run npm run fix, you appear to be having some TypeScript linting issues, hence the breaking builds.

@bcoe we are using this in js. I do not have the command npm run fix. On multiple machines and from multiple users the issue keeps arising. It also happens across all apis, not just one. Once we implement the change, the code works perfect. But we keep having to manually go in and make the change.

@JustinBeckwith JustinBeckwith merged commit da1e230 into googleapis:master Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants