-
Notifications
You must be signed in to change notification settings - Fork 141
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 coercing of string to 0 in parse_id #173
Conversation
Currently, parse_id returns a 0 if a string is passed in, rather than a hash. This extends the check on the resource to ensure it is a hash and allows normal error handling to proceed.
Checked commit jntullo@7bd90ca with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 spec/requests/services_spec.rb
|
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 couldn't find a better place for the test, seems like it doesn't quite belong there and is more of a general case. Thoughts?
I think adding tests for specific bugs that happen to test general cases is fine; it's covered somewhere :)
LGTM
@@ -39,7 +39,7 @@ def validate_api_action | |||
end | |||
|
|||
def parse_id(resource, collection) | |||
return nil if resource.blank? | |||
return nil if !resource.kind_of?(Hash) || resource.blank? |
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.
You don't need resource.blank?
anymore, though it's fine that it short circuits the case
below.
Thanks @jntullo for fixing this 👍 |
Fix coercing of string to 0 in parse_id (cherry picked from commit 42813a2)
Gaprindashvili backport details:
|
Currently, parse_id returns a 0 if a string is passed in, rather than a hash. This checks to ensure the resource passed in is a hash and returns nil otherwise, allowing normal error handling to proceed.
I couldn't find a better place for the test, seems like it doesn't quite belong there and is more of a general case. Thoughts?
@miq-bot add_label bug, gaprindashvili/yes