Skip to content

Commit

Permalink
Merge pull request #6092 from mirumee/handle-none-as-attribute-value
Browse files Browse the repository at this point in the history
Handle None as attribute value
  • Loading branch information
maarcingebala committed Sep 2, 2020
2 parents b06cd35 + fccadae commit 344dffc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -45,6 +45,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Fix incorrect calculation of subtotal with active Avatax - #6035 by @korycins
- Fix incorrect assigment of tax_code for Avatax - #6035 by @korycins
- Do not allow negative product price - #6091 by @IKarbowiak
- Handle None as attribute value - #6092 by @IKarbowiak

## 2.10.2

Expand Down
2 changes: 2 additions & 0 deletions saleor/graphql/product/tests/test_variant.py
Expand Up @@ -819,6 +819,7 @@ def test_update_product_variant_with_duplicated_attribute(
([], "size expects a value but none were given"),
(["one", "two"], "A variant attribute cannot take more than one value"),
([" "], "Attribute values cannot be blank"),
([None], "Attribute values cannot be blank"),
),
)
def test_update_product_variant_requires_values(
Expand All @@ -828,6 +829,7 @@ def test_update_product_variant_requires_values(
- No values
- Blank value
- None as value
- More than one value
"""

Expand Down
2 changes: 1 addition & 1 deletion saleor/graphql/product/utils.py
Expand Up @@ -50,7 +50,7 @@ def validate_attribute_input_for_variant(instance: "Attribute", values: List[str
code=ProductErrorCode.INVALID.value,
)

if not values[0].strip():
if values[0] is None or not values[0].strip():
raise ValidationError(
"Attribute values cannot be blank", code=ProductErrorCode.REQUIRED.value
)
Expand Down

0 comments on commit 344dffc

Please sign in to comment.