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

Take into account semantical 'errors' key in JSON body for 422 responses #677

Conversation

vbyno
Copy link
Contributor

@vbyno vbyno commented Jan 29, 2020

According to the documentation, there might be errors key containing an array of error messages. In this PR we check if the response body has errors key if we didn't found error

@vbyno vbyno requested a review from a team as a code owner January 29, 2020 13:42
@vbyno vbyno force-pushed the take_into_account_errors_key_upon_enriching_error_message branch from 7285391 to 402d8f4 Compare January 29, 2020 13:46
Copy link
Contributor

@tanema tanema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence, there is no point in enriching messages for any response but one
with 422 code.

Is it detrimental to the other error codes? If not I think we should keep the whole range in. I do appreaciate you adding the errors check as well. One thing we could do is call super if errors are undefined or the JSON is invalid to capture all cases.

lib/shopify_api/message_enricher.rb Outdated Show resolved Hide resolved
According to the documentation
https://help.shopify.com/en/api/getting-started/response-status-codes:
  422 Unprocessable Entity
  The request body was well-formed but contains semantical errors.
  The response body will provide more details in the errors or
  error parameters.

Hence, there is no point in enriching messages for any response but one
with 422 code.
There might be `errors` key containing array of error messages. This is
handled as well
@vbyno vbyno force-pushed the take_into_account_errors_key_upon_enriching_error_message branch from 402d8f4 to 1b63054 Compare January 29, 2020 14:48
@vbyno
Copy link
Contributor Author

vbyno commented Jan 29, 2020

One thing we could do is call super if errors are undefined or the JSON is invalid to capture all cases.

@tanema , It looks to me that is already implemented here
https://github.com/Shopify/shopify_api/pull/677/files#diff-0c1174150b76ca5c6e7e2a5513559edfR15-R20

Copy link
Contributor

@tanema tanema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect thanks for the change!

@tanema tanema merged commit 66550c9 into Shopify:master Jan 29, 2020
@tanema
Copy link
Contributor

tanema commented Jan 29, 2020

I think it will be a little while before this is deployed and added to our other gems because we are currently propagating a new version right now

@vbyno
Copy link
Contributor Author

vbyno commented Jan 29, 2020

@tanema , no problem. Thanks!

@toneymathews toneymathews temporarily deployed to rubygems February 24, 2020 21:24 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants