Skip to content

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

Open
@ghost

Description

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

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

Development

No branches or pull requests

Issue actions