Skip to content

Different validation between attribute creation and update via REST API #36327

Open
@ghost

Description

@ghost

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": {
    "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"
    }
    }
    -> attribute will be created, but with BE type text (due to getBackendTypeByInput() function)

Expected result

Correct backend_type will be created if valid in body, or throw exception if wrong backend_type provided or fallback to current behavior if backend_type not mentioned.

Actual result

Wrong backend type is set on attribute

Screenshot 2022-10-21 at 4 56 44 PM

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

Activity

m2-assistant

m2-assistant commented on Oct 18, 2022

@m2-assistant

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.


⚠️ 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.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

self-assigned this
on Oct 19, 2022
m2-assistant

m2-assistant commented on Oct 19, 2022

@m2-assistant

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

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

engcom-Bravo

engcom-Bravo commented on Oct 19, 2022

@engcom-Bravo
Contributor

@magento give me 2.4-develop instance

magento-deployment-service

magento-deployment-service commented on Oct 19, 2022

@magento-deployment-service

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

engcom-Bravo

engcom-Bravo commented on Oct 19, 2022

@engcom-Bravo
Contributor

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.

ghost
engcom-Bravo

engcom-Bravo commented on Oct 20, 2022

@engcom-Bravo
Contributor

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.

ghost
engcom-Bravo

engcom-Bravo commented on Oct 21, 2022

@engcom-Bravo
Contributor

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.

23 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: APIsComponent: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Pull Request In Progress

Milestone

No milestone

Relationships

None yet

    Participants

    @engcom-Bravo@engcom-Delta@engcom-Hotel@github-jira-sync-bot@rogerdz

    Issue actions

      Different validation between attribute creation and update via REST API · Issue #36327 · magento/magento2