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

Update Error Classification mechanism #7

Merged
merged 2 commits into from
Jan 28, 2021

Conversation

JuanCrg90
Copy link
Contributor

Mercado Libre doesn't have a uniform error structure. For example the
invalid_token error has in the error key "not_found"

{ "message": "invalid_token", "error": "not_found", "status": 401, "cause":[] }

Or malformed access_token comes as a bad_request error

{ "message": "Malformed access_token: test","error": "bad_request", "status": 400, "cause":[] }

This updates the error classification mechanism to use the description
as the first alternative to classify the error.

end

def test_invalid_token_error
assert_token_error('error' => 'invalid_token')
body = { "message": "invalid_token", "error": "not_found", "status": 401, "cause":[] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the error responses from recorded vcr files, I don't have a vcr for the forbidden error, but we can update it in case the error message is different.

Mercado Libre doesn't have a uniform error structure. For example the
invalid_token error has in the error key "not_found"

{ "message": "invalid_token", "error": "not_found", "status": 401, "cause":[] }

Or malformed access_token comes as a bad_request error

{ "message": "Malformed access_token: test","error": "bad_request", "status": 400, "cause":[] }

This updates the error classification mechanism to use the description
as the first alternative to classify the error.
@JuanCrg90 JuanCrg90 force-pushed the improve_error_classification branch from 544161f to aa2077e Compare January 28, 2021 01:26
status_error = STATUS_ERRORS[response.code]
raise status_error.new(response) if status_error
def error_message_from_body(response)
return if response.body.nil?
Copy link
Contributor Author

@JuanCrg90 JuanCrg90 Jan 28, 2021

Choose a reason for hiding this comment

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

[DEPRECATION] HTTParty will no longer override response#nil?. This functionality will be removed in future versions. Please, add explicit check response.body.nil? || response.body.empty?. For more info refer to: jnunemaker/httparty#568

@JuanCrg90 JuanCrg90 requested a review from enortham January 28, 2021 01:28
@JuanCrg90 JuanCrg90 self-assigned this Jan 28, 2021
@JuanCrg90 JuanCrg90 force-pushed the improve_error_classification branch from aa2077e to 617690c Compare January 28, 2021 01:42
@JuanCrg90 JuanCrg90 requested a review from enortham January 28, 2021 01:46
@JuanCrg90
Copy link
Contributor Author

@enortham friendly reminder

@JuanCrg90 JuanCrg90 merged commit 2e756a4 into master Jan 28, 2021
@JuanCrg90 JuanCrg90 deleted the improve_error_classification branch January 28, 2021 17:31
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.

2 participants