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
Safer argument parsing (attempt 2) #221
Conversation
454aab6
to
5af03b2
Compare
Ugh, that sucks. Github should really get with the times and show the diff as what the final merge will look like, a la Bitbucket |
The |
(Also, note that the Travis tests are currently failing.) |
4da0903
to
257347d
Compare
@russelldavis I backed out most of those I actually think that spec failing is flakiness in the spec itself. Ruby 1.8 doesn't preserve hash ordering so the resulting query string can be different. I've patched the spec here. |
@@ -22,7 +23,7 @@ def self.retrieve(id=nil, opts={}) | |||
opts = id | |||
id = nil | |||
end | |||
super(id, opts) | |||
super(id, Util.normalize_opts(opts)) |
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.
This looks like another unnecessary call to normalize_opts
, since super
already calls it.
(After this, I think the PR will be ready to merge -- sorry for the delay.)
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.
cool, it's gone
@bobjflong thanks for pushing this through! |
I couldn't stomach the merge conflicts in #220 (I was working with an old fork).
An issue I've seen crop up is that if a global key is set (which most of your docs use), and then client API keys are used (eg. if using OAuth), then unexpected results can happen. This includes loading customer data from the parent global key.
With my changes:
I've also added
normalize_opts
usage to a bunch of places. I'm sure not all of these are necessary. I've added tests for the staticself.foo
ones. It is a slight flaw I think that the current "normalization" of opts is spread across lots of resources, when it should be enforced centrally. I have some ideas about how to do that. But I think with a look over, this could be a good step forward and prevent some nasty errors.