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

validation issue with async bulk api when sending products with missing attributes #39527

Open
1 of 5 tasks
mhaagen85 opened this issue Jan 9, 2025 · 2 comments
Open
1 of 5 tasks

Comments

@mhaagen85
Copy link

mhaagen85 commented Jan 9, 2025

Preconditions and environment

  • Magento version : 2.4.6-p8
  • When sending products via asyn bulk api where there are products with missing attributes, they will bypass the validation and empty products are created in Magento.
  • This happends when there is a product with a non default attribute set which already exists and after this product a new product with default attribute set is handled. This attribute set Id is not loaded, only the former attributeset. Then when checking if attributes are applicable it is not passed the isInSet and the attribute is not validated. And the product can be created even with missing attributes.

files:

  • vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php line 86
  • vendor/magento/module-eav/Model/Entity/Attribute/AbstractAttribute.php line 745
  • vendor/magento/module-catalog/Model/ProductRepository.php line 579
  • vendor/magento/module-eav/Model/Entity/Attribute/Set.php line 311

Steps to reproduce

Send 2 product via async/bulk/V1/products: for example:
[ { "product": { "sku": "existing sku", "type_id": "simple", "created_at": null, "updated_at": null, "custom_attributes": [ { "attribute_code": "cost", "value": "201.96" } ] } }, { "product": { "sku": "new sku", "type_id": "simple", "created_at": null, "updated_at": null, "custom_attributes": [ { "attribute_code": "cost", "value": "28.65" } ] } } ]

The existing product needs to have an custom attribute set. The second will fallback on the default. When the first is handled the custom attribute set is loaded by $productAttributes = $product->getAttributes(); in the ProductRepository after the validation is done. Then when the 2nd product is handled the attribute set which is diffirent from the first one, is not loaded and when checking if the attribute set id is on the attribute it fails and then the attribute is not applicable and is not handled by the validation.

Expected result

Products with missing data for required attributes are not created

Actual result

products with missing data are being created

Additional information

No response

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 Jan 9, 2025

Hi @mhaagen85. 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.


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.

@mhaagen85
Copy link
Author

mhaagen85 commented Jan 9, 2025

Temp fix. trigger get attributes before the validation in Model/ProductRepository.php:
$product->getAttributes(); $validationResult = $this->resourceModel->validate($product);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant