Different validation between attribute creation and update via REST API
Preconditions and environment
- Magento 2.4.4,2.4-develop
- REST API access
- Create Product attributes with options through rest API
Steps to reproduce
Issue a request following these criteria
- Request method: POST
- Endpoint: /rest/V1/products/attributes
- example Body: { "attribute": { "iswysiwygenabled": false, "ishtml_allowed_onfront": false, "usedfor_sortby": false, "is_filterable": true, "isfilterable_insearch": true, "isused_ingrid": true, "isvisible_ingrid": false, "isfilterable_ingrid": true, "position": 0, "apply_to": <], "is_searchable": "1", "isvisible_in_advancedsearch": "1", "is_comparable": "1", "isused_for_promorules": "0", "isvisible_onfront": "0", "usedin_productlisting": "1", "is_visible": true, "scope": "global", "attribute_code": "brand", "frontend_input": "select", "entitytypeid": "4", "is_required": false, "options": [ { "label": "test1" }, { "label": "test2" }, { "label": "test3" } ], "isuserdefined": true, "defaultfrontendlabel": "Brand", "frontend_labels": null, "backend_type": "decimal", "source_model": "Magento%5C%5CEav%5C%5CModel%5C%5CEntity%5C%5CAttribute%5C%5CSource%5C%5CTable", "default_value": "", "is_unique": "0" } } -> attribute will be created, but with BE type text (due to getBackendTypeByInput() function)
Expected result
Correct backendtype will be created if valid in body, or throw exception if wrong backend_type provided or fallback to current behavior if backendtype not mentioned.
Actual result
Wrong backend type is set on attribute
[img width="950" alt="Screenshot 2022-10-21 at 4 56 44 PM" src="https://user-images.githubusercontent.com/51680745/197205328-2a519ab7-3208-48d0-a30b-9d3e79bf68f8.png"]
Additional information
Please do not use select frontend type for this case. to reproduce the issue use the text front end type.
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.
- [X] 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".
Hi @mansourwalid. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
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:
@magento give me 2.4-develop instance - upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
- Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: 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.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-Bravo. 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: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced 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: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.4-develop instance
Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Bravo, here is your Magento Instance: https://0deb0e79ae377da4a9abffb95472f464.instances.magento-community.engineering Admin access: https://0deb0e79ae377da4a9abffb95472f464.instances.magento-community.engineering/admin_475b Login: e8bbb47e Password: c173ad63f57f
Hi @mansourwalid,
Thank you for reporting and collaboration.Verified the issue on Magento 2.4-develop instance.
We have used this body for attributes
{ "attribute": { "is_wysiwyg_enabled": false, "is_html_allowed_on_front": false, "used_for_sort_by": false, "is_filterable": true, "is_filterable_in_search": true, "is_used_in_grid": true, "is_visible_in_grid": false, "is_filterable_in_grid": true, "position": 0, "apply_to": [], "is_searchable": "1", "is_visible_in_advanced_search": "1", "is_comparable": "1", "is_used_for_promo_rules": "0", "is_visible_on_front": "0", "used_in_product_listing": "1", "is_visible": true, "scope": "global", "attribute_code": "brand", "frontend_input": "select", "entity_type_id": "4", "is_required": false, "options": [ { "label": "test1" }, { "label": "test2" }, { "label": "test3" } ], "is_user_defined": true, "default_frontend_label": "Brand", "frontend_labels": null, "backend_type": "int", "source_model": "Magento%5C%5CEav%5C%5CModel%5C%5CEntity%5C%5CAttribute%5C%5CSource%5C%5CTable", "default_value": "", "is_unique": "0" } }
please confirm in your case also you are getting same kind of Difference.
As you mentioned repeat call not possible it shows attribute is already created.kindly provide more steps about this.
Please let us know we miss anything.
Thanks.
Hi @engcom-Bravo , thanks for checking out this issue. I explicitly mentioned in the example I made that the frontend input time is "text" and not a select. We dont need the attribute to be a select.
Can you test with such case please ?
Hi @mansourwalid,
Thanks for quick update.
We tried with "frontend_input": "text"..Please provide more information about repeat call.Kindly refer screenshots.
Please let us know we miss anything.
Thanks.
Hi @engcom-Bravo,
Thanks again for taking care of the request.
you have successfully reproduced the issue. As you can see, the API request call mention a backend_type to be decimalwhile in the response, the attribute was created with backend_type varchar which is not expected.
Hi @mansourwalid,
Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop instance and the issue is reproducible. Kindly refer the screenshots.
We are getting Wrong backend type in the response.
Hence confirming this issue.
Thanks.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6885 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi @mansourwalid,,
Thanks for your reporting and collaboration. We have re-verified the issue in latest 2.4-develop instance hence reconfirming the issue. Kindly refer the screenshots.
Steps to reproduce : 1.Request method: POST 2. Endpoint: /rest/V1/products/attributes example Body: { "attribute": { "is_wysiwyg_enabled": false, "is_html_allowed_on_front": false, "used_for_sort_by": false, "is_filterable": true, "is_filterable_in_search": true, "is_used_in_grid": true, "is_visible_in_grid": false, "is_filterable_in_grid": true, "position": 0, "apply_to": [], "is_searchable": "1", "is_visible_in_advanced_search": "1", "is_comparable": "1", "is_used_for_promo_rules": "0", "is_visible_on_front": "0", "used_in_product_listing": "1", "is_visible": true, "scope": "global", "attribute_code": "brand", "frontend_input": "select", "entity_type_id": "4", "is_required": false, "options": [ { "label": "test1" }, { "label": "test2" }, { "label": "test3" } ], "is_user_defined": true, "default_frontend_label": "Brand", "frontend_labels": null, "backend_type": "decimal", "source_model": "Magento%5C%5CEav%5C%5CModel%5C%5CEntity%5C%5CAttribute%5C%5CSource%5C%5CTable", "default_value": "", "is_unique": "0" } }
Thanks.
Hi @ghost,
Adobe Commerce Engineering team started working on this issue. We will reach out to you if we need more information and you will get notified once the issue is fixed. Please leave comments for any further questions. Thank you!