Skip to content

GraphQl customer orders query failed if try to retreive order item with deleted product #38900

Open
@zakdma

Description

@zakdma

Preconditions and environment

  • Magento version 2.4.7-p1 (latest)

Steps to reproduce

  1. Install vanilla Magento instance
  2. Go to admin and create new simple product with SKU: simple-deleted
  3. Fill in all necessary product data to display it on front (stock, price, category etc.) and save it
  4. Reindex all
  5. Go to front and create new customer
  6. Find and add simple-deleted product to cart
  7. Go to checkout and place an order using some address data and default shipping and billing methods
  8. Go to admin and see the order is in Sales/Orders grid
  9. 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/
  10. Use the generated token in the following requests by adding it to Authorization header according to Magento GraphQl documentation
  11. perform query
query {
  customer {
    orders(currentPage: 1, pageSize: 999) {
      items {
        number
        items {
          product {
            sku
            name
          }
        }
      }
    }
  }
}
  1. See the correct response like this
{
  "data": {
    "customer": {
      "orders": {
        "items": [
          {
            "number": "000000001",
            "items": [
              {
                "product": {
                  "sku": "simple-deleted",
                  "name": "simple-deleted"
                }
              }
            ]
          }
        ]
      }
    }
  }
}
  1. Go to admin and delete product simple-deleted
  2. 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.
  • 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”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: OrderComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.7-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions