Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
fix clean seo data error when null is passed (#13533)
Shreyans Suraliyae03ee76d2b89
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b51d9babd6..fe67c6dc47 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -134,6 +134,8 @@ Shipping methods can be removed by the user after it has been assigned to a chec- Add missing descriptions to Translation module. - #13410 by @Smit-Parmar- Add missing descriptions to menu module - #13409 by @devilsautumn- Add missing descriptions to page module - #13536 by @devilsautumn+- Fix seo field to accept null value - #13512 by @ssuraliya+# 3.14.0diff --git a/saleor/graphql/core/tests/test_validators.py b/saleor/graphql/core/tests/test_validators.pyindex c57ef55606..a9d213a6f1 100644--- a/saleor/graphql/core/tests/test_validators.py+++ b/saleor/graphql/core/tests/test_validators.py@@ -101,6 +101,12 @@ def test_clean_seo_fields():assert data["seo_description"] == description+def test_clean_seo_fields_accepts_null():+ data = {"seo": None}+ clean_seo_fields(data)+ assert not data++@pytest.mark.parametrize("cleaned_input",[diff --git a/saleor/graphql/core/validators/__init__.py b/saleor/graphql/core/validators/__init__.pyindex a3c0c60668..997bd92c48 100644--- a/saleor/graphql/core/validators/__init__.py+++ b/saleor/graphql/core/validators/__init__.py@@ -178,11 +178,12 @@ def clean_seo_fields(data):"""Extract and assign seo fields to given dictionary."""seo_fields = data.pop("seo", {})- if "title" in seo_fields:- data["seo_title"] = seo_fields["title"]+ if seo_fields:+ if "title" in seo_fields:+ data["seo_title"] = seo_fields["title"]- if "description" in seo_fields:- data["seo_description"] = seo_fields["description"]+ if "description" in seo_fields:+ data["seo_description"] = seo_fields["description"]def validate_required_string_field(cleaned_input, field_name: str):