magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Different validation between attribute creation and update via REST API

Open ghost opened this issue 3 years ago • 14 comments

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".

ghost avatar Oct 18 '22 21:10 ghost

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.


: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

m2-assistant[bot] avatar Oct 18 '22 21:10 m2-assistant[bot]

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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components 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.

m2-assistant[bot] avatar Oct 19 '22 04:10 m2-assistant[bot]

@magento give me 2.4-develop instance

engcom-Bravo avatar Oct 19 '22 09:10 engcom-Bravo

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" } }

Screenshot 2022-10-19 at 5 19 50 PM

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.

Screenshot 2022-10-19 at 5 20 13 PM

Please let us know we miss anything.

Thanks.

engcom-Bravo avatar Oct 19 '22 12:10 engcom-Bravo

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 ?

ghost avatar Oct 19 '22 15:10 ghost

Hi @mansourwalid,

Thanks for quick update.

We tried with "frontend_input": "text"..Please provide more information about repeat call.Kindly refer screenshots.

Screenshot 2022-10-20 at 5 20 57 PM Screenshot 2022-10-20 at 5 21 08 PM

Please let us know we miss anything.

Thanks.

engcom-Bravo avatar Oct 20 '22 12:10 engcom-Bravo

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.

ghost avatar Oct 20 '22 14:10 ghost

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.

Screenshot 2022-10-21 at 4 56 44 PM

Hence confirming this issue.

Thanks.

engcom-Bravo avatar Oct 21 '22 12:10 engcom-Bravo

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

github-jira-sync-bot avatar Oct 21 '22 13:10 github-jira-sync-bot

: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.

m2-assistant[bot] avatar Oct 21 '22 13:10 m2-assistant[bot]

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" } }

Image

Thanks.

engcom-Delta avatar Apr 08 '25 13:04 engcom-Delta

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!

engcom-Bravo avatar Dec 04 '25 06:12 engcom-Bravo