-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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] payment_mercado_pago: handle mercado pago no body responses #152102
[FIX] payment_mercado_pago: handle mercado pago no body responses #152102
Conversation
f5b85e6
to
f9f289c
Compare
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.
looks ok if we don't get a json response and don't have any more info
I can't reproduce with the steps (I get on the https://sandbox.mercadopago.com.mx/ website and I don't get any error). I don't know what extra tabs meant in "access token for mercado pago with extra tabs" so maybe that's why.
If we add information about why the call fails, it would be useful to give it in the error_message.
Unfortunately we don't get any more information from mercado pago, so that's why. |
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.
Yes we're not discarding it. This will stay as is. In order to reproduce this specific bug you need to pad the access token with tab spaces. In that case mercado pago will not respond with that known error. Instead, it will respond with status code 403 only and now we're handling that 403 response. |
Could you share a runbot that has the problem? It works just fine (clear error) for me. |
Can you try here: https://57568658-master-all.runbot185.odoo.com/shop/payment |
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.
Ok this time I could reproduce. Maybe I didn't pad my token enough 🤷
error_code = response.status_code | ||
error_message = '' |
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 think we should not try to force dummy error codes and messages into the existing ValidationError text; "information (code 403)" is useless to users.
Instead, we should raise a different ValidationError ("The communication with the API failed. The response is empty. Please verify your access token."
) when a ValueError exception is raised. Also, there should be a comment "The API response is sometimes empty when the access token is wrong.".
f9f289c
to
0864c79
Compare
Issue: When using a mercado pago invalid access token with extra tabs, we get 403 response from mercado pago without a body which raises and exception while handling this exception we fail to parse the response as it has no body. line causing the issue: https://github.com/odoo/odoo/blob/9764e6f7fe39a10f3b04e1764110d8c274d0431a/addons/payment_mercado_pago/models/payment_provider.py#L70 Steps to reproduce: 1- Enable mercado pago as a payment provider 2- Set a valid access token for mercado pago with extra tabs 3- Go to website 4- Fill the cart 5- Checkout with the cart using mercado pago 6- You see error message of unhandled json parsing error Solution: We should wrap parsing the response in a try statement to handle the responses without body opw-3654133
0864c79
to
64acf96
Compare
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.
@robodoo delegate+
@robodoo r+ |
Issue: When using a mercado pago invalid access token with extra tabs, we get 403 response from mercado pago without a body which raises and exception while handling this exception we fail to parse the response as it has no body. line causing the issue: https://github.com/odoo/odoo/blob/9764e6f7fe39a10f3b04e1764110d8c274d0431a/addons/payment_mercado_pago/models/payment_provider.py#L70 Steps to reproduce: 1- Enable mercado pago as a payment provider 2- Set a valid access token for mercado pago with extra tabs 3- Go to website 4- Fill the cart 5- Checkout with the cart using mercado pago 6- You see error message of unhandled json parsing error Solution: We should wrap parsing the response in a try statement to handle the responses without body opw-3654133 closes #152102 Signed-off-by: Omar Abosamaha (abom) <[email protected]>
Issue: When using a mercado pago invalid access token with extra tabs, we get 403 response from mercado pago without a body which raises and exception while handling this exception we fail to parse the response as it has no body. line causing the issue: https://github.com/odoo/odoo/blob/9764e6f7fe39a10f3b04e1764110d8c274d0431a/addons/payment_mercado_pago/models/payment_provider.py#L70 Steps to reproduce: 1- Enable mercado pago as a payment provider 2- Set a valid access token for mercado pago with extra tabs 3- Go to website 4- Fill the cart 5- Checkout with the cart using mercado pago 6- You see error message of unhandled json parsing error Solution: We should wrap parsing the response in a try statement to handle the responses without body opw-3654133 closes odoo#152102 Signed-off-by: Omar Abosamaha (abom) <[email protected]>
Issue: When using a mercado pago invalid access token with extra tabs, we get 403 response from mercado pago without a body which raises and exception while handling this exception we fail to parse the response as it has no body. line causing the issue: https://github.com/odoo/odoo/blob/9764e6f7fe39a10f3b04e1764110d8c274d0431a/addons/payment_mercado_pago/models/payment_provider.py#L70 Steps to reproduce: 1- Enable mercado pago as a payment provider 2- Set a valid access token for mercado pago with extra tabs 3- Go to website 4- Fill the cart 5- Checkout with the cart using mercado pago 6- You see error message of unhandled json parsing error Solution: We should wrap parsing the response in a try statement to handle the responses without body opw-3654133 closes odoo/odoo#152102 Signed-off-by: Omar Abosamaha (abom) <[email protected]>
[FIX] payment_mercado_pago: handle mercado pago no body responses
Issue:
When using a mercado pago invalid access token with extra tabs, we get 403 response from mercado pago without a body which raises and exception while handling this exception we fail to parse the response as it has no body.
line causing the issue:
odoo/addons/payment_mercado_pago/models/payment_provider.py
Line 70 in 9764e6f
Steps to reproduce:
1- Enable mercado pago as a payment provider
2- Set a valid access token for mercado pago with extra tabs 3- Go to website
4- Fill the cart
5- Checkout with the cart using mercado pago
6- You see error message of unhandled json parsing error
Solution:
We should wrap parsing the response in a try statement to handle the responses without body
opw-3654133
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr