{"data":{"id":"magento2-33139","source":"github-pr","sourceRef":"magento/magento2#33139","title":"Rest API and Magento backend use different validation methods for attribute_code when creating new attributes","pr":{"number":33139,"url":"https://github.com/magento/magento2/pull/33139","author":"homecoded","mergedAt":"2026-01-31T13:09:39Z","mergeCommit":"b3b61fc3639d82cf456048558d879cd79094e674","headCommit":"2ace85359508380fa4e24cac04ea7503f35ec738","baseRef":"2.4-develop","diffSha256":"ac7ffd402a6c9096172d32f801b627960779bac4176a86d6bdb65e8f87014e3e"},"issues":[{"number":33138,"url":"https://github.com/magento/magento2/issues/33138","title":"Rest API and Magento backend use different validation methods for attribute_code when creating new attributes","labels":["Area: APIs","Component: Api","Issue: Confirmed","Priority: P2","Progress: PR Created","Progress: PR in progress","Progress: done","Reported on 2.4.2","Reproduced on 2.4.x"],"kind":"human"}],"fixedIn":"2.4.9","containingTags":["2.4.9"],"reportedOn":"2.4.2","codeMatch":{"2.4.6":"clean","2.4.6-p1":"clean","2.4.6-p2":"clean","2.4.6-p3":"clean","2.4.6-p4":"clean","2.4.6-p5":"clean","2.4.6-p6":"clean","2.4.6-p7":"clean","2.4.6-p8":"clean","2.4.6-p9":"clean","2.4.6-p10":"clean","2.4.6-p11":"clean","2.4.6-p12":"clean","2.4.6-p13":"clean","2.4.6-p14":"clean","2.4.6-p15":"clean","2.4.7":"clean","2.4.7-p1":"clean","2.4.7-p2":"clean","2.4.7-p3":"clean","2.4.7-p4":"clean","2.4.7-p5":"clean","2.4.7-p6":"clean","2.4.7-p7":"clean","2.4.7-p8":"clean","2.4.7-p9":"clean","2.4.7-p10":"clean","2.4.8":"clean","2.4.8-p1":"clean","2.4.8-p2":"clean","2.4.8-p3":"clean","2.4.8-p4":"clean","2.4.8-p5":"clean","2.4.9":"conflict"},"affectedVersions":["2.4.6","2.4.6-p1","2.4.6-p2","2.4.6-p3","2.4.6-p4","2.4.6-p5","2.4.6-p6","2.4.6-p7","2.4.6-p8","2.4.6-p9","2.4.6-p10","2.4.6-p11","2.4.6-p12","2.4.6-p13","2.4.6-p14","2.4.6-p15","2.4.7","2.4.7-p1","2.4.7-p2","2.4.7-p3","2.4.7-p4","2.4.7-p5","2.4.7-p6","2.4.7-p7","2.4.7-p8","2.4.7-p9","2.4.7-p10","2.4.8","2.4.8-p1","2.4.8-p2","2.4.8-p3","2.4.8-p4","2.4.8-p5"],"components":["magento/module-catalog"],"files":[{"path":"app/code/Magento/Catalog/Model/Product/Attribute/Repository.php","change":"modified","package":"magento/module-catalog"}],"stripped":{"tests":["app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php"],"docs":[],"outsideCode":[]},"linesChanged":17,"mergeBatched":false,"excluded":null,"sections":{"description":"1. I can create product attributes with uppercase letters in attribute_code through backend.\n2. I **cannot** create product attributes with uppercase letters in attribute_code **through Rest API**.\n3. Backend and rest api do not work similarly in creating product attributes in regards to attribute_code.-","stepsToReproduce":"1. Go to backend \n2. Open Stores -> Attribute -> Product \n3. Click \"Add New Attribute\"\n4. Enter arbitrary value in \"Default Label\"\n5. Under \"Advanced Attribute Properties\" enter an \"Attribute Code\" that contains an upper case letter, e.g. \"Test_Attribute\"\n6. Hit save (works!)\n7. Setup Rest-API and send a request  to create a product attribute with an attribute code that has uppercase letters, e.g. \"Test_Attribute2\" (see sample script below)\n8. Check response: `\"message\":\"Invalid value of \"\"%value\"\" provided for the %fieldName field.\",\"parameters\":{\"fieldName\":\"attribute_code\",\"value\":\"Test_Attribute2\"}`\n\nSample bash script for verification (replace baseurl and username/password)\n\n``` \nBASE_URL='http://localhost/'\nTOKEN=$(curl -X POST \"${BASE_URL}index.php/rest/V1/integration/admin/token\" \\\n-H \"Content-Type:application/json\" \\\n-d '{\"username\":\"admin\", \"password\":\"password123\"}')\nTOKEN=$(echo $TOKEN | sed \"s/\\\"//g\");\n\ncurl -X POST \"${BASE_URL}index.php/rest/V1/products/attributes\" \\\n-H \"authorization: Bearer ${TOKEN}\" \\\n-H 'content-type: application/json' \\\n-d '{\n \"attribute\": {\n   \"attribute_code\": \"branding_Tester4\",\n   \"default_frontend_label\": \"Testing\",\n   \"frontend_input\": \"text\"\n }\n}'\n```","expectedResult":"1. I expect that I can create the same kind of product attributes through backend and Rest-API  \n2. I expect that I can use uppercase letters in attribute codes when creating product attributes through backend and frontend. \n3. I expect that backend and rest api work similarly in creating product attributes.","actualResult":"1. I can create product attributes with uppercase letters in attribute_code through backend.\n2. I **cannot** create product attributes with uppercase letters in attribute_code **through Rest API**.\n3. Backend and rest api do not work similarly in creating product attributes in regards to attribute_code.-\n\n---\nPlease provide [Severity](https://devdocs.magento.com/guides/v2.4/contributor-guide/contributing.html#backlog) assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.\n\n- [ ] Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._\n- [ ] Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._\n- [x] Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._\n- [ ] Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._\n- [ ] Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._","source":"issue"},"signatures":[],"labels":{"area":["APIs"],"component":["Api"],"priority":"P2","severity":null,"reportedOn":["2.4.2"]},"categories":["Web API"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"7f430672565b7496ebf0243932b3faa022a21a49cc5fc7bdb5f02474089fa132","isBugfix":0.9562,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.9278,"feature":0.0096,"refactor":0.0467,"tests_only":0.0088,"docs_only":0.0032,"dependency":0.0039},"confidence":0.8358},"scope":{"score":0.829,"probabilities":{"0":0.3256,"1":0.5198,"2":0.1546},"confidence":0.1002},"risk":{"score":0.3957,"probabilities":{"0":0.6563,"1":0.2917,"2":0.052},"confidence":0.2778},"area":{"choice":"catalog","probabilities":{"catalog":0.6132,"checkout":0.0044,"customer":0.0033,"admin":0.0416,"graphql_api":0.3085,"framework":0.0143,"frontend":0.0043,"other":0.0104},"confidence":0.398},"securityRelevant":0.0108,"reportedVersion":{"choice":"2.4.2","probabilities":{"2.4.0":0.0043,"2.4.0-p1":0.0027,"2.4.1":0.0061,"2.4.1-p1":0.0037,"2.4.2":0.6318,"2.4.2-p1":0.0425,"2.4.2-p2":0.0481,"2.4.3":0.0057,"2.4.3-p1":0.0053,"2.4.3-p2":0.0078,"2.4.3-p3":0.0051,"2.4.4":0.0064,"2.4.4-p1":0.0041,"2.4.4-p10":0.003,"2.4.4-p11":0.0037,"2.4.4-p12":0.0036,"2.4.4-p13":0.0031,"2.4.4-p14":0.0034,"2.4.4-p15":0.0031,"2.4.4-p16":0.003,"2.4.4-p17":0.0028,"2.4.4-p18":0.0027,"2.4.4-p2":0.0034,"2.4.4-p3":0.0028,"2.4.4-p4":0.0036,"2.4.4-p5":0.0035,"2.4.4-p6":0.0032,"2.4.4-p7":0.0031,"2.4.4-p8":0.0032,"2.4.4-p9":0.0025,"2.4.5":0.0033,"2.4.5-p1":0.0031,"2.4.5-p10":0.0024,"2.4.5-p11":0.0031,"2.4.5-p12":0.0035,"2.4.5-p13":0.0028,"2.4.5-p14":0.0033,"2.4.5-p15":0.0025,"2.4.5-p16":0.0022,"2.4.5-p17":0.0027,"2.4.5-p2":0.0028,"2.4.5-p3":0.0027,"2.4.5-p4":0.0032,"2.4.5-p5":0.0026,"2.4.5-p6":0.0035,"2.4.5-p7":0.003,"2.4.5-p8":0.0025,"2.4.5-p9":0.002,"2.4.6":0.0035,"2.4.6-p1":0.0037,"2.4.6-p10":0.0035,"2.4.6-p11":0.003,"2.4.6-p12":0.0033,"2.4.6-p13":0.0035,"2.4.6-p14":0.0036,"2.4.6-p15":0.0027,"2.4.6-p2":0.0028,"2.4.6-p3":0.0031,"2.4.6-p4":0.0042,"2.4.6-p5":0.003,"2.4.6-p6":0.0039,"2.4.6-p7":0.0033,"2.4.6-p8":0.0028,"2.4.6-p9":0.0022,"2.4.7":0.0028,"2.4.7-p1":0.003,"2.4.7-p10":0.003,"2.4.7-p2":0.0031,"2.4.7-p3":0.0039,"2.4.7-p4":0.0049,"2.4.7-p5":0.004,"2.4.7-p6":0.0048,"2.4.7-p7":0.0038,"2.4.7-p8":0.0035,"2.4.7-p9":0.0024,"2.4.8":0.0031,"2.4.8-p1":0.0029,"2.4.8-p2":0.0037,"2.4.8-p3":0.0039,"2.4.8-p4":0.0046,"2.4.8-p5":0.0037,"2.4.9":0.0036,"unspecified":0.0047},"confidence":0.397},"backportWorthy":{"score":1.5597,"probabilities":{"0":0.0914,"1":0.2575,"2":0.6511},"confidence":0.2479}},"curated":{"title":"Fixes the Rest API rejecting capital letters in product attribute codes","description":"When creating product attributes through the Rest-API, attributes created cannot have capital letters in the attribute code, while attributes created through backend can. The validateCode method now uses Magento\\Eav\\Model\\Validator\\Attribute\\Code::isValid, so both behave the same.","categories":["Web API"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":{"2.4.8-p5":{"before":"pass","after":"pass","adapted":false,"runAt":"2026-10-06T09:20:11.783Z","releaseCommit":"870a22c63d9d9b68fa3297962e2d5d5841115814","suites":{"unit":{"before":"pass","after":"pass","runAt":"2026-10-06T09:20:11.783Z"}}},"2.4.7-p10":{"before":"pass","after":"pass","adapted":false,"runAt":"2026-10-06T09:29:07.896Z","releaseCommit":"72561bf80652f57cc642a03e2c9a51d74a285b14","suites":{"unit":{"before":"pass","after":"pass","runAt":"2026-10-06T09:29:07.896Z"}}}}},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-33139 details"}