Skip to content

GraphQl products query returns error: Warning: Array to string conversion in vendor/magento/module-catalog-graph-ql/Model/Resolver/Product/ProductCustomAttributes.php on line 111 #39912

Open
@mrrobotisback

Description

@mrrobotisback

Preconditions and environment

Preconditions and environment
Magento version 2.4.7-p4
OpenSearch search engine configured and used by Magento

Steps to reproduce

  1. Install vanilla Magento

  2. create Size attribute DropDown attribute with code size and options: xs, s, m, l, xl, xxl 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
    • Add attribute test_ddl to default Attribute set
  4. On existing color attribute add option: red, green, black

  5. Create new configurable product in admin with SKU test

    • name: Test
    • sku: test
    • price: 0
  6. Save configurable product

  7. Crea new Simple product in admin with SKU test-simple

    • name: test-simple
    • sku: test-simple
    • price: 55
    • tier price: all websites, all groups, 50, fixed, 45
    • quantity: 100
    • stock status: in stock
    • color: red
    • size: xs
  8. Save simple product

  9. reopen configurable product

    • link simple to configurable by color and size
    • save
    • set stock status: in stock
    • save
  10. run indexer:reindex , ca:cl, ca:fl

  11. make GraphQL query:

    products(filter: { url_key: { eq: "test" } }) {
        total_count
        items {
            canonical_url
            color
					  size
            manufacturer
            meta_description
            meta_keyword
            meta_title
            name
            new_from_date
            new_to_date
            only_x_left_in_stock
            options_container
            rating_summary
            review_count
            sku
            special_from_date
            special_price
            special_to_date
            stock_status
            swatch_image
            tier_price
            type_id
            uid
            updated_at
            url_key
            url_path
            url_suffix
            description {
                html
            }
            ... on ConfigurableProduct {
                variants {
                    product {
                        color
											  size
                        only_x_left_in_stock
                        sku
                        stock_status
                        custom_attributesV2 {
                            items {
                                code
                                ... on AttributeValue {
                                    code
                                    value
                                }
                                ... on AttributeSelectedOptions {
                                    code
                                }
                            }
                        }
                    }
                    attributes {
                        code
                        label
                    }
                }
            }
            custom_attributesV2 {
                items {
                    code
                    ... on AttributeValue {
                        code
                        value
                    }
                }
            }
        }
    }
}

Expected result

There is list of products with the test product in it.
There is no error

Actual result

{
	"errors": [
		{
			"message": "Internal server error",
			"locations": [
				{
					"line": 62,
					"column": 13
				}
			],
			"path": [
				"products",
				"items",
				0,
				"custom_attributesV2"
			],
			"extensions": {
				"debugMessage": "Magento\\EavGraphQl\\Model\\Output\\Value\\GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given, called in \/var\/www\/html\/magento\/vendor\/magento\/module-catalog-graph-ql\/Model\/Resolver\/Product\/ProductCustomAttributes.php on line 122"
			}
		},
		{
			"message": "Internal server error",
			"locations": [
				{
					"line": 43,
					"column": 25
				}
			],
			"path": [
				"products",
				"items",
				0,
				"variants",
				0,
				"product",
				"custom_attributesV2"
			],
			"extensions": {
				"debugMessage": "Warning: Array to string conversion in \/var\/www\/html\/magento\/vendor\/magento\/module-catalog-graph-ql\/Model\/Resolver\/Product\/ProductCustomAttributes.php on line 111"
			}
		}
	],
	"data": {
		"products": {
			"total_count": 1,
			"items": [
				{
					"canonical_url": null,
					"color": null,
					"size": null,
					"manufacturer": null,
					"meta_description": "Test",
					"meta_keyword": "Test",
					"meta_title": "Test",
					"name": "Test",
					"new_from_date": null,
					"new_to_date": null,
					"only_x_left_in_stock": null,
					"options_container": "container2",
					"rating_summary": 0,
					"review_count": 0,
					"sku": "Test",
					"special_from_date": null,
					"special_price": null,
					"special_to_date": null,
					"stock_status": "IN_STOCK",
					"swatch_image": null,
					"tier_price": null,
					"type_id": "configurable",
					"uid": "MQ==",
					"updated_at": "2025-05-13 12:36:02",
					"url_key": "test",
					"url_path": null,
					"url_suffix": ".html",
					"description": {
						"html": ""
					},
					"variants": [
						{
							"product": {
								"color": 10,
								"size": 4,
								"only_x_left_in_stock": null,
								"sku": "test-simple",
								"stock_status": "IN_STOCK",
								"custom_attributesV2": null
							},
							"attributes": [
								{
									"code": "color",
									"label": "red"
								},
								{
									"code": "size",
									"label": "xs"
								}
							]
						}
					],
					"custom_attributesV2": null
				}
			]
		}
	}
}

Additional information

After apply this patch -> #38884 (comment)
I still have this error:

{
	"errors": [
		{
			"message": "Internal server error",
			"locations": [
				{
					"line": 43,
					"column": 25
				}
			],
			"path": [
				"products",
				"items",
				0,
				"variants",
				0,
				"product",
				"custom_attributesV2"
			],
			"extensions": {
				"debugMessage": "Warning: Array to string conversion in \/var\/www\/html\/magento\/vendor\/magento\/module-catalog-graph-ql\/Model\/Resolver\/Product\/ProductCustomAttributes.php on line 111"
			}
		}
	],
	"data": {
		"products": {
			"total_count": 1,
			"items": [
				{
					"canonical_url": null,
					"color": null,
					"size": null,
					"manufacturer": null,
					"meta_description": "Test",
					"meta_keyword": "Test",
					"meta_title": "Test",
					"name": "Test",
					"new_from_date": null,
					"new_to_date": null,
					"only_x_left_in_stock": null,
					"options_container": "container2",
					"rating_summary": 0,
					"review_count": 0,
					"sku": "Test",
					"special_from_date": null,
					"special_price": null,
					"special_to_date": null,
					"stock_status": "IN_STOCK",
					"swatch_image": null,
					"tier_price": null,
					"type_id": "configurable",
					"uid": "MQ==",
					"updated_at": "2025-05-13 12:36:02",
					"url_key": "test",
					"url_path": null,
					"url_suffix": ".html",
					"description": {
						"html": ""
					},
					"variants": [
						{
							"product": {
								"color": 10,
								"size": 4,
								"only_x_left_in_stock": null,
								"sku": "test-simple",
								"stock_status": "IN_STOCK",
								"custom_attributesV2": null
							},
							"attributes": [
								{
									"code": "color",
									"label": "red"
								},
								{
									"code": "size",
									"label": "xs"
								}
							]
						}
					],
					"custom_attributesV2": {
						"items": [
							{
								"code": "name",
								"value": "Test"
							},
							{
								"code": "manufacturer"
							},
							{
								"code": "meta_title",
								"value": "Test"
							},
							{
								"code": "meta_keyword",
								"value": "Test"
							},
							{
								"code": "meta_description",
								"value": "Test"
							},
							{
								"code": "status"
							},
							{
								"code": "visibility"
							},
							{
								"code": "page_layout"
							},
							{
								"code": "options_container"
							},
							{
								"code": "url_key",
								"value": "test"
							},
							{
								"code": "msrp_display_actual_price_type"
							},
							{
								"code": "gift_message_available"
							},
							{
								"code": "tax_class_id"
							}
						]
					}
				}
			]
		}
	}
}

because on this line 2.4.7-p4
vendor/magento/module-catalog-graph-ql/Model/Resolver/Product/ProductCustomAttributes.php:111
when evaluate tier_prices is an array of array.

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

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.7-p4Indicates original Magento version for the Issue report.

Type

No type

Projects

Status

Needs Update

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions