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(moduleExec): pass correct object to validation #27

Merged
merged 2 commits into from
Feb 9, 2021

Conversation

pudgereyem
Copy link
Contributor

@pudgereyem pudgereyem commented Feb 8, 2021

This PR fixes #24

Changes

  • moduleExec: Change so that we always pass an object to validateAndCoerceTypes
  • quote: no need to default to empty object for overrides since that is done later

@gadicc
Copy link
Owner

gadicc commented Feb 9, 2021

Thanks for another PR!

Umm, on looking at the issue in #27 I think I'd prefer to go the simpler route of just defaulting to an empty object, rather than validating the default options (that never change) on every call. So instead of the objectToValidate const could we just change the

    object: queryOpts.overrides,

to

    object: queryOpts.overrides ?? {},

I'm going to add a quick test for this to make sure it works just as well. Thanks again :)

@pudgereyem
Copy link
Contributor Author

@gadicc Ah, I see your viewpoint.

I thought it made sense to validate "ALL" query parameters, since theoretically queryOpts.overrides could change and not pass the validation? Or is this being validate elsewhere?

I saw that you solved this in another way here but it's better to account for this in moduleExec I believe. Then we can remove that.

I'll update the PR with your suggested change, but if you have time please respond to my first question.

@pudgereyem
Copy link
Contributor Author

@gadicc this should be good to go now! And hopefully fixes the broken test that you've added here; 8017659

I think it's a really good practice to do when we found a bug btw, to add the broken test and then fix it. Nice one 💯

@gadicc
Copy link
Owner

gadicc commented Feb 9, 2021

Awesome, thanks, @pudgereyem! 🙌

And yes adding the broken test first is a great habit! I love it. I'll add a note about it on the contributing doc too.

I thought it made sense to validate "ALL" query parameters, since theoretically queryOpts.overrides could change and not pass the validation? Or is this being validate elsewhere?

I think you mean the queryOpts.defaults, right? Essentially Yahoo validates this for us on the request, so if these's a mistake in here it will get picked up during testing (although I guess I should add some URL validation into fetchDevel at some point). The defaults are set when we publish the package, they don't change at runtime and can only be overriden.

I saw that you solved this in another way here but it's better to account for this in moduleExec I believe. Then we can remove that.

You're absolutely right about this, thanks for cleaning up my code in quote too! 🙏

@gadicc gadicc merged commit 8b0f9c7 into gadicc:devel Feb 9, 2021
@pudgereyem
Copy link
Contributor Author

I think you mean the queryOpts.defaults, right? Essentially Yahoo validates this for us on the request, so if these's a mistake in here it will get picked up during testing (although I guess I should add some URL validation into fetchDevel at some point). The defaults are set when we publish the package, they don't change at runtime and can only be overriden.

Yes, I mean queryOpts.defaults, sorry for the typo! Yeah, I see what you mean! All good 👍

@pudgereyem pudgereyem deleted the fix/validate branch February 9, 2021 17:39
gadicc pushed a commit that referenced this pull request Feb 10, 2021
# [1.7.0](v1.6.0...v1.7.0) (2021-02-10)

### Bug Fixes

* **index:** uhhhh s/_options/_opts/ like it's called everywhere else ([4492993](4492993))
* **moduleExec:** pass correct object to validation ([#27](#27)) ([8b0f9c7](8b0f9c7))
* **modules:** change overloading order specificy (fixes [#21](#21)) ([1806e61](1806e61))
* **quote:** extend marketState property ([0c36a60](0c36a60))
* **quote:** interface fixes, 10am UTC tests ([#35](#35)) ([1c256c7](1c256c7))

### Features

* new module recommendationsBySymbol ([#28](#28)) ([b467acb](b467acb))
@gadicc
Copy link
Owner

gadicc commented Feb 10, 2021

🎉 This PR is included in version 1.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid options ("#/definitions/SearchOptions")
2 participants