Skip to content

Disable product that relate to another product make graphql break when query. #28892

Closed
@forfin

Description

@forfin

Preconditions (*)

  1. Magento Open Source 2.4-develop, 2.3.5-p1 fresh install

Steps to reproduce (*)

  1. Create first product (name: test-01).
  2. Create another product (name: test-02). + Add test-01 as related products
  3. Disable product test-01
  4. Send graphql request to get relate product
curl -X POST \
  http://magento-2-fresh/graphql \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{"query":"  query productDetail {\n    productDetail: products(pageSize: 10, currentPage: 1, search: \"\") {\n      items {\n        id\n        sku\n        name\n        related_products {\n          id\n          sku\n          url_key\n        }\n      }\n    }\n  }","operationName":"productDetail"}'
  • Graphql format
query productDetail {
  productDetail: products(pageSize: 10, currentPage: 1, search: "") {
    items {
      id
      sku
      name
      related_products {
        id
        sku
        url_key
      }
    }
  }
}

Expected result (*)

  1. json response with no error
{
    "data": {
        "productDetail": {
            "items": [
                {
                    "id": 2,
                    "sku": "Test-02",
                    "name": "Test-02",
                    "related_products": []
                }
            ]
        }
    }
}

Actual result (*)

{
    "errors": [
        {
            "debugMessage": "Notice: Undefined offset: 1 in /app/vendor/magento/module-related-product-graph-ql/Model/Resolver/Batch/AbstractLikedProducts.php on line 115",
            "message": "Internal server error",
            "extensions": {
                "category": "internal"
            },
            "locations": [
                {
                    "line": 7,
                    "column": 9
                }
            ],
            "path": [
                "productDetail",
                "items",
                0,
                "related_products"
            ]
        }
    ],
    "data": {
        "productDetail": {
            "items": [
                {
                    "id": 2,
                    "sku": "Test-02",
                    "name": "Test-02",
                    "related_products": null
                }
            ]
        }
    }
}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • 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

Labels

Component: RelatedProductGraphQlFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.3.5-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions