Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty attribute values cause an exception #342

Open
JulienPalard opened this issue Apr 4, 2024 · 0 comments
Open

Empty attribute values cause an exception #342

JulienPalard opened this issue Apr 4, 2024 · 0 comments

Comments

@JulienPalard
Copy link
Contributor

When creating a product in the sandbox (in current main branch):

$ curl --user mdk:supersecret -XPOST http://localhost:8000/api/admin/products/ -H "Content-Type: application/json" -d '{"product_class": "testtype", "slug": "test", "attributes": [{"code": "text", "value": "1"}]}'

it works, but when I use an empty value, like:

$ curl --user mdk:supersecret -XPOST http://localhost:8000/api/admin/products/ -H "Content-Type: application/json" -d '{"product_class": "testtype", "slug": "test", "attributes": [{"code": "text", "value": ""}]}'

I'm getting a 500 error.

It looks like it's due to the ProductAttributeValueSerializer's update_or_create method doing:

attribute.save_value(product, value)
return product.attribute_values.get(attribute=attribute)

the save may not save empty values (which looks OK to me) so the following get fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant