Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 5 tasks
zakdma opened this issue Jun 27, 2024 · 19 comments
Labels
Area: Product Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.7-p1 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@zakdma
Copy link
Contributor

zakdma commented Jun 27, 2024

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”.
Copy link

m2-assistant bot commented Jun 27, 2024

Hi @zakdma. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

Copy link

m2-assistant bot commented Jun 27, 2024

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@zakdma
Copy link
Contributor Author

zakdma commented Jun 27, 2024

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.

@engcom-Delta
Copy link
Contributor

engcom-Delta commented Jul 1, 2024

Hi @zakdma ,

Verified the issue on 2.4-develop and we are not able to reproduce this issue.

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
4.Add attribute test_ddl to default Attribute set
5.Create new product in admin with SKU simple-null
6.Add Price, Stock, Category. Set test_ddl to Option 1
7.Save product
8.Open edit product form again and change test_ddl to empty value
9.Open any graphql client and make query

created attribute

Screenshot 2024-07-01 at 5 49 44 PM

the values

Screenshot 2024-07-01 at 5 50 05 PM Screenshot 2024-07-01 at 5 50 10 PM

added to default attribute set

Screenshot 2024-07-01 at 5 51 13 PM

product created and value saved to option 1

Screenshot 2024-07-01 at 5 53 59 PM

product edited value emptied and saved

Screenshot 2024-07-01 at 5 55 06 PM

no error

Screenshot 2024-07-01 at 6 02 16 PM

Please refer the attached screenshots and let us know if we missed anything.

@engcom-Delta engcom-Delta added the Issue: needs update Additional information is require, waiting for response label Jul 1, 2024
@engcom-Delta engcom-Delta added the Reported on 2.4.7-p1 Indicates original Magento version for the Issue report. label Jul 1, 2024
@OvalMedia
Copy link

Why am I getting this response? I did not report or comment on this.

@zakdma
Copy link
Contributor Author

zakdma commented Jul 2, 2024

Hey @engcom-Delta
Is far as I can see from your screenshots you are not using vanilla Magento. You Magento instance has a lot of attribute sets and maybe also other data, modules or configurations. Please use vanilla magento that can be installed like this
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition public

Also please use OpenSearch as a search engine and reindex all indexes bin/magento ind:reind before making graphql request
Please make sure they all reindexed successfully.

Regards.

@engcom-Delta
Copy link
Contributor

Hi @zakdma ,

Verified the issue on 2.4-develop and we are not able to reproduce this issue.

Preconditions:-

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
4.Add attribute test_ddl to default Attribute set
5.Create new product in admin with SKU simple-null
6.Add Price, Stock, Category. Set test_ddl to Option 1
7.Save product
8.Open edit product form again and change test_ddl to empty value
9.Reindex all indexes bin/magento indexer:reindex Please make sure they all reindexed successfully
10.Open any graphql client and make query

Created new attribute

Screenshot 2024-07-02 at 7 02 56 PM Screenshot 2024-07-02 at 7 03 03 PM Screenshot 2024-07-02 at 7 03 14 PM

added on default test attribute

Screenshot 2024-07-02 at 7 03 51 PM

Created new product

Screenshot 2024-07-02 at 7 08 59 PM

edited product

Screenshot 2024-07-02 at 7 09 34 PM

Reindex all indexes

Screenshot 2024-07-02 at 7 10 20 PM

Actual result: We are not getting internal server error

Screenshot 2024-07-02 at 7 37 06 PM

Please refer the attached screenshots and let us know if we missed anything.

@zakdma
Copy link
Contributor Author

zakdma commented Jul 2, 2024

Hey @engcom-Delta
Don't you see an error on your screenshot? https://prnt.sc/j2P8ngjnBGGS
Your request didn't return any result because of an indexation error. https://prnt.sc/T9jaBXFsuii6
That's why you don't see error 500

@mattijv
Copy link
Contributor

mattijv commented Jul 3, 2024

Can confirm that we've run into this exact same issue. I think it might be easiest to hit if you don't use any filters in the custom_attributesV2 query, but just try getting all the attributes.

@mattijv
Copy link
Contributor

mattijv commented Jul 3, 2024

@magento give me 2.4-develop instance

Copy link

Hi @mattijv. Thank you for your request. I'm working on Magento instance for you.

Copy link

@mattijv
Copy link
Contributor

mattijv commented Jul 3, 2024

I was able to reproduce the issue (not the exact same steps, but it's the same underlying issue) in the dev instance provisioned above.

Steps:

  1. Add a tier price to a product (I used SKU 24-WB04).
  2. Wait for indexers to run (not sure this is necessary).
  3. Query the custom_attributesV2 field for that product.

Screenshot from 2024-07-03 11-04-47
Screenshot from 2024-07-03 11-05-36

Here's the query used for copypaste convenience:

{
  products(filter: {sku: {eq:"24-WB04"}}) {
    items {
      sku
      custom_attributesV2 {
        items {
          code
          ... on AttributeValue {
            value
          }
          ... on AttributeSelectedOptions {
            selected_options {
              value
            }
          }
        }
      }
    }
  }
}

@engcom-Delta
Copy link
Contributor

Hi @zakdma,

Verified the issue on 2.4-develop and 2.4.7 and it is reproducible.

Hence, Confirming the issue.

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
4.Add attribute test_ddl to default Attribute set
5.Create new product in admin with SKU simple-null
6.Add Price, Stock, Category. Set test_ddl to Option 1
7.Save product
8.Open edit product form again and change test_ddl to empty value
9.Reindex all indexes bin/magento indexer:reindex Please make sure they all reindexed successfully
10.Open any graphql client and make query

created attribute

Screenshot 2024-07-02 at 7 02 56 PM

attribute settings

Screenshot 2024-07-02 at 7 03 03 PM Screenshot 2024-07-02 at 7 03 14 PM

attribute added to default attribute set

Screenshot 2024-07-02 at 7 03 51 PM

Created new product

Screenshot 2024-07-02 at 7 08 59 PM

edited product

Screenshot 2024-07-02 at 7 09 34 PM

reindexing

Screenshot 2024-07-03 at 2 15 35 PM

Graphql result

Screenshot 2024-07-03 at 2 03 34 PM

Exception log

Screenshot 2024-07-03 at 2 17 33 PM

@engcom-Delta engcom-Delta added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: GraphQL GraphQL Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Product labels Jul 3, 2024
@engcom-Delta engcom-Delta removed the Issue: needs update Additional information is require, waiting for response label Jul 3, 2024
@m2-community-project m2-community-project bot added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jul 3, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-12328 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Jul 3, 2024

✅ Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@m2-community-project m2-community-project bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jul 3, 2024
@engcom-Delta engcom-Delta added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Jul 3, 2024
@github-jira-sync-bot
Copy link

❌ You don't have permission to export this issue.

@zakdma
Copy link
Contributor Author

zakdma commented Jul 3, 2024

Hey @engcom-Delta @mattijv
Thank you for confirming the issue. The same problem can appear for any attribute value that is not a string. For example, I faced it for the int value, but the issue reproducing is a bit complicated. As far as I can see this resolver is implemented for product, customer and quote address attributes.
There some workaround patches I created to make it working before issue fixed.

--- a/Model/Customer/Address/ExtractCustomerAddressData.php
+++ b/Model/Customer/Address/ExtractCustomerAddressData.php
@@ -162,7 +162,7 @@
                 return $this->getAttributeValue->execute(
                     AddressMetadataInterface::ENTITY_TYPE_ADDRESS,
                     $customAttribute['attribute_code'],
-                    $customAttribute['value']
+                    (string)$customAttribute['value']
                 );
             },
             $attributes
--- a/Model/Resolver/Product/ProductCustomAttributes.php
+++ b/Model/Resolver/Product/ProductCustomAttributes.php
@@ -122,7 +122,7 @@
                     return $this->getAttributeValue->execute(
                         ProductAttributeInterface::ENTITY_TYPE_CODE,
                         $customAttribute['attribute_code'],
-                        $customAttribute['value']
+                        (string)$customAttribute['value']
                     );
                 },
                 $customAttributes
--- a/Model/Cart/ExtractQuoteAddressData.php
+++ b/Model/Cart/ExtractQuoteAddressData.php
@@ -86,7 +86,7 @@
                         return $this->getAttributeValue->execute(
                             'customer_address',
                             $attribute->getAttributeCode(),
-                            $attribute->getValue()
+                            (string)$attribute->getValue()
                         );
                     },
                     $address->getCustomAttributes() ?? []

@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-12328

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jul 4, 2024
@zakdma zakdma changed the title GraphQl products query returns erro: GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given GraphQl products query returns error: GetAttributeValueComposite::execute(): Argument #3 ($value) must be of type string, null given Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Product Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.7-p1 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Status: Ready for Development
Development

No branches or pull requests

6 participants