Skip to content

GraphQl products query returns error: GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given #38884

Open
@zakdma

Description

@zakdma

Preconditions and environment

  • Magento version 2.4.7-p1 (latest for now)
  • OpenSearch search engine configured and used by Magento

Steps to reproduce

  1. Install vanilla Magento
  2. Create DropDown attribute with code test_ddl and options: Option 1, Option 2, Option 3 and Values Required: No
  3. Set attribute parameters
  • Use in Search: Yes
  • Use in Layered Navigation: Filterable (with results)
  • Use in Search Results Layered Navigation: Yes
  • Visible on Catalog Pages on Storefront: Yes
  • Used in Product Listing: Yes
  1. Add attribute test_ddl to default Attribute set
  2. Create new product in admin with SKU simple-null
  3. Add Price, Stock, Category. Set test_ddl to Option 1
  4. Save product
  5. Open edit product form again and change test_ddl to empty value https://prnt.sc/9BdefPLEi8M4
  6. Reindex all indexes bin/magento ind:reind Please make sure they all reindexed successfully
  7. Open any graphql client and make query
query {
    products(
      search: "simple"
    ) {
        total_count
        items {
            name
            sku
            custom_attributesV2(filters: {is_visible_on_front: true}) {
              items {
                code
                ... on AttributeValue {
                      value
                    }
                ... on AttributeSelectedOptions {
                      selected_options {
                        value
                      }
                    }
              }
            }
        }
        aggregations{
           attribute_code
           options{
             value
           }
        }
        page_info {
            page_size
            current_page
        }
    }
 }

Expected result

There is list of products with the simple-null product in it.
There is no error

Actual result

There is error in response

  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 12,
          "column": 13
        }
      ],
      "path": [
        "products",
        "items",
        3,
        "custom_attributesV2"
      ]
    }
  ],

Check exception.log and see error:

[2024-06-27T10:00:50.656107+00:00] main.ERROR: Magento\EavGraphQl\Model\Output\Value\GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given, called in /home/zak/sites/magento/test1/public/vendor/magento/module-catalog-graph-ql/Model/Resolver/Product/ProductCustomAttributes.php on line 122

GraphQL (12:13)
11:             sku
12:             custom_attributesV2(filters: {is_visible_on_front: true}) {
                ^
13:               items {
 {"exception":"[object] (GraphQL\\Error\\Error(code: 0): Magento\\EavGraphQl\\Model\\Output\\Value\\GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given, called in /home/zak/sites/magento/test1/public/vendor/magento/module-catalog-graph-ql/Model/Resolver/Product/ProductCustomAttributes.php on line 122 at /home/zak/sites/magento/test1/public/vendor/webonyx/graphql-php/src/Error/Error.php:170)
[previous exception] [object] (TypeError(code: 0): Magento\\EavGraphQl\\Model\\Output\\Value\\GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given, called in /home/zak/sites/magento/test1/public/vendor/magento/module-catalog-graph-ql/Model/Resolver/Product/ProductCustomAttributes.php on line 122 at /home/zak/sites/magento/test1/public/vendor/magento/module-eav-graph-ql/Model/Output/Value/GetAttributeValueComposite.php:34)"} []

Additional information

Issue is because \Magento\EavGraphQl\Model\Output\Value\GetAttributeValueInterface::execute hase third paremeter $value of type string when null value received.

Note: Just so you know, the problem is not only with null/string. There is also a problem with any other value type other than string. For example if value is int there will be the same error.
I found the same issue when I added the quote address custom attribute with int type. When setting this attribute value using setShippingAddressesOnCart and retrieving the shipping address it also failed.

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: ProductComponent: 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