-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
bug: placeOrder error handling is incompatible with GraphQl norms #39300
Comments
Hi @damienwebdev. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
+1 This is a huge issue and a breaking change for this mutation In {
"data": {
"placeOrder": {
"order": null
}
}
} Unreal. This is a blocker for any upgrades or security patches. @damienwebdev thank you for reporting this issue. |
Note that this same breaking pattern has already been introduced into the 2.4-develop branch for the UpdateCartItems resolver in this commit. If Adobe does not nip this in the bud now, it's going to spread. |
Just wanted to chime in and confirm the severity of this issue. Because exceptions are caught and transformed into items in the The conversion of exceptions (into a pre-defined code + message) also seems to be done in such a way that it would not work properly if exception messages are translated (which is likely to be the case since it is catching |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @damienwebdev @JesKingDev @hnsr, Thanks for the report and collaboration! We have tried to reproduce the issue in the latest development branch i.e. 2.4-develop and we can create an order using the I understand you are talking about an exception running the above query. Please let us know the reproduction steps for the same. Thanks |
Expected Response {
"errors": [
{
"message": "Guest email for cart is missing.",
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"placeOrder"
],
"extensions": {
"category": "graphql-input"
}
}
],
"data": {
"placeOrder": null
}
} Actual Response {
"data": {
"placeOrder": {
"order": null
}
}
} The GraphQL spec per GraphQl.org requires errors to be separate from data. https://spec.graphql.org/October2021/#sec-Errors.Error-result-format This is a breaking schema change that would require all of our GraphQL clients to change their behavior away from the GraphQl spec, such as popular clients like Apollo. https://www.apollographql.com/docs/react/data/error-handling#graphql-error-policies. Further, this breaking schema change was initially introduced in a security patch which feels like an oversight and is a significant change that should at least warrant deprecation. |
Thanks @JesKingDev for the reply! We ran the below mutation on Guest Cart for creating an order:
And we are able to get the proper exception as follows:
Please refer to the screenshot below for reference: Please let us know if we missed anything. Thanks |
You missed something. Please read the original issue before you triage.
Before the inclusion of {
errors: [
{ "message": " Something went wrong, etc etc..." }
]
} Most GraphQl clients interpret this as an error and appropriately cause error handling behaviors. After the inclusion of 8e3a2e0#diff-ac993812eff9f7c3da3b41215860c173b0e83438a39cb16a1f3332672e2c8eab an error results in: {
data: {
placeOrder: {
order: null,
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
},
} If anything, at the worst, this should be: {
data: {
placeOrder: {
order: null,
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
}
errors: [
{ "message": " Something went wrong, etc etc..." }
]
} |
I believe you have acurately reproduced the problem with this; the errors are returned through a new In addition to this:
|
Thanks @hnsr @damienwebdev for more information! We got the point now. We are confirming this issue for further processing. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-13357 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
This builds upon #39282
Before the inclusion of
errors
onPlaceOrderOutput
as a result of this commit if an error occured, the response to a failed place order would look like:Most GraphQl clients interpret this as an error and appropriately cause error handling behaviors.
After the inclusion of 8e3a2e0#diff-ac993812eff9f7c3da3b41215860c173b0e83438a39cb16a1f3332672e2c8eab an error results in:
If anything, at the worst, this should be:
Error handling should match the common well-defined behaviors outlined by clients like Apollo. It should not be some bespoke poorly considered implementation.
Additionally, 8e3a2e0 inadvertently causes New Relic alarms to be silenced since failed
placeOrder
attempts are now returned as "success" as https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php#L53 is never called.The text was updated successfully, but these errors were encountered: