Skip to content

Do not validate length and input rule if attribute value is required but empty #22003

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

Conversation

VincentMarmiesse
Copy link
Contributor

Hi,

Description (*)

The EAV text attribute validation continues even if a required attribute is required but has no value.
It raises the error

Argument 2 passed to Magento\Eav\Model\Attribute\Data\Text::validateLength() must be of the type string, null given, called in /var/www/html/vendor/magento/module-eav/Model/Attribute/Data/Text.php on line 80

when creating a customer without a required attribute with GraphQL for example.

Manual testing scenarios (*)

  1. Create a required customer attribute
  2. Register a new customer with GraphQL request createCustomer but without setting this required attribute
  3. Magento should return the error "Attribute" is a required value.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param array|string $value such value as null must not be passed to this method. Please filter it out on higher level.

@VincentMarmiesse
Copy link
Contributor Author

@orlangur Ok so you want me to change these lines: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Eav/Model/Validator/Attribute/Data.php#L128-L130 right?

We could change it to

if (!isset($data[$attributeCode])) {
   continue;
}

what do you think?

@engcom-Foxtrot
Copy link
Contributor

@VincentMarmiesse please update PR, or we will close it as inactive.

@VincentMarmiesse
Copy link
Contributor Author

Hi @engcom-dev-Foxtrot,
I'm not sure what I need to do, I'm waiting for @orlangur advice.

@sidolov
Copy link
Contributor

sidolov commented Aug 13, 2019

@param array|string $value such value as null must not be passed to this method. Please filter it out on higher level.

It does not make sense to validate the value that equal to null.

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-5616 has been created to process this Pull Request
✳️ @sidolov, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Before:

before

After:

after

@m2-assistant
Copy link

m2-assistant bot commented Aug 27, 2019

Hi @VincentMarmiesse, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Aug 27, 2019
@sidolov sidolov added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests Component: Eav Progress: accept Release Line: 2.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants