Magento ver. 2.2.5 using the REST API.
{
"option": {
"label": "30",
"value": "30",
"sort_order": 0,
"is_default": false,
"store_labels": [{
"store_id": 0,
"label": "30"
}]
}
}{
"message": "Cannot save attribute %1",
"parameters": ["size"]
} and a 400 status codeThis is happening when the attribute is a number, and a number alone. It also happens with floating point numbers, such as 6.5.
Hi @sidm. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento-engcom-team give me {$VERSION} instance
where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.
@sidm do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
@magento-engcom-team give me 2.2.5 instance
Hi @sidm. Thank you for your request. I'm working on Magento 2.2.5 instance for you
Hi @sidm, here is your Magento instance.
Admin access: https://i-18009-2-2-5.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.
Yes, I was able to reproduce this on the vanilla instance.
Steps:



{"option":{"label":"30","value":"30","sort_order":0,"is_default":false,"store_labels":[{"store_id":0,"label":"30"}]}}"{"message":"Cannot save attribute %1","parameters":["size"]}"
I also verified that the same call worked with a non-numeric value, using this body
{"option":{"label":"test","value":"test","sort_order":0,"is_default":false,"store_labels":[{"store_id":0,"label":"test"}]}} and received a 200 status code

you can see that the "test" attribute option now appears in the attribute

Hi @sidm , thank you for your report.
We've acknowledged the issue and added to our backlog.
Created PRs for 2.2 and 2.3.
Created PRs for 2.2 and 2.3.
Can you please link me to them?
@p-bystritsky
@sidm they are located in private Magento Engcom team repository.
@p-bystritsky Could you tell me what to change to fix this issue, or provide me with the code for the changed files?
Hi @sidm. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#2158 by @p-bystritsky in 2.2-develop branch
Related commit(s):
The fix will be available with the upcoming 2.2.8 release.
Hi @sidm. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#2159 by @p-bystritsky in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.1 release.
Note that this change "breaks" the way \Magento\Eav\Model\Entity\Attribute\OptionManagement::add could be used to e.g. update options' store-specific labels, and now it always creates a new option in the database.
This is because \Magento\Eav\Model\ResourceModel\Entity\Attribute::_updateAttributeOption checks if the $optionId is numeric, and does an insert if it's not.
To me it looks like this fix (https://github.com/magento/magento2/commit/3b9e96360e71b5d38167068b2b1a069ca97dc672) is trying to fix something that isn't broken.
Proof
Conclusion
Option value (option ID) should not be provided in the request when creating new options. If this is acceptable, then this fix should be just reverted. Otherwise, fix should be changed so that resource model allows to create new option with given option ID and this 'id_' prefix fix is removed.
Most helpful comment
To me it looks like this fix (https://github.com/magento/magento2/commit/3b9e96360e71b5d38167068b2b1a069ca97dc672) is trying to fix something that isn't broken.
Proof
Conclusion
Option value (option ID) should not be provided in the request when creating new options. If this is acceptable, then this fix should be just reverted. Otherwise, fix should be changed so that resource model allows to create new option with given option ID and this 'id_' prefix fix is removed.