magento2
magento2 copied to clipboard
GraphQl customer orders query failed if try to retreive order item with deleted product
Preconditions and environment
- Magento version 2.4.7-p1 (latest)
Steps to reproduce
- Install vanilla Magento instance
- Go to admin and create new simple product with SKU:
simple-deleted
- Fill in all necessary product data to display it on front (stock, price, category etc.) and save it
- Reindex all
- Go to front and create new customer
- Find and add
simple-deleted
product to cart - Go to checkout and place an order using some address data and default shipping and billing methods
- Go to admin and see the order is in
Sales/Orders
grid - Open any GraphQl client and generate token using
generateCustomerToken
GraphQl mutation using previously created customer credentials https://developer.adobe.com/commerce/webapi/graphql/schema/customer/mutations/generate-token/ - Use the generated token in the following requests by adding it to Authorization header according to Magento GraphQl documentation
- perform query
query {
customer {
orders(currentPage: 1, pageSize: 999) {
items {
number
items {
product {
sku
name
}
}
}
}
}
}
- See the correct response like this
{
"data": {
"customer": {
"orders": {
"items": [
{
"number": "000000001",
"items": [
{
"product": {
"sku": "simple-deleted",
"name": "simple-deleted"
}
}
]
}
]
}
}
}
}
- Go to admin and delete product simple-deleted
- Perform the query again
query {
customer {
orders(currentPage: 1, pageSize: 999) {
items {
number
items {
product {
sku
name
}
}
}
}
}
}
Expected result
There is a correct response with the data requested without any error
Actual result
There is error response like this
{
"errors": [
{
"message": "Internal server error",
"locations": [
{
"line": 7,
"column": 11
}
],
"path": [
"customer",
"orders",
"items",
0,
"items",
0,
"product"
]
}
],
"data": {
"customer": {
"orders": {
"items": [
{
"number": "000000001",
"items": [
{
"product": null
}
]
}
]
}
}
}
}
Additional information
Check exception.log and see error like this
[2024-07-03T15:09:43.938496+00:00] main.ERROR: Missing key "associatedProduct" in Order Item value data
GraphQL (40:11)
39: }
40: product {
^
41: id
{"exception":"[object] (GraphQL\\Error\\Error(code: 0): Missing key \"associatedProduct\" in Order Item value data at /var/www/app/vendor/webonyx/graphql-php/src/Error/Error.php:155)
[previous exception] [object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): Missing key \"associatedProduct\" in Order Item value data at /var/www/app/vendor/magento/module-sales-graph-ql/Model/Resolver/ProductResolver.php:46)"} []
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.