Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Unify sth-does-not-exist error codes
Aleksander Spyrad0fefb7d32c3
diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.pyindex d02a23173a..964e46ee59 100644--- a/saleor/graphql/account/mutations/base.py+++ b/saleor/graphql/account/mutations/base.py@@ -20,7 +20,7 @@ from ...core.mutations import (UpdateMetaBaseMutation,validation_error_to_error_type,)-from ...core.utils.error_codes import AccountErrorCode+from ...core.utils.error_codes import AccountErrorCode, CommonErrorCodeBILLING_ADDRESS_FIELD = "default_billing_address"SHIPPING_ADDRESS_FIELD = "default_shipping_address"@@ -75,7 +75,7 @@ class SetPassword(CreateToken):raise ValidationError({"email": ValidationError(- "User doesn't exist", code=AccountErrorCode.USER_DOES_NOT_EXIST+ "User doesn't exist", code=CommonErrorCode.OBJECT_DOES_NOT_EXIST)})@@ -126,7 +126,7 @@ class RequestPasswordReset(BaseMutation):{"email": ValidationError("User with this email doesn't exist",- code=AccountErrorCode.USER_DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/account/mutations/deprecated_account.py b/saleor/graphql/account/mutations/deprecated_account.pyindex 2782ae61c3..d32a5835c5 100644--- a/saleor/graphql/account/mutations/deprecated_account.py+++ b/saleor/graphql/account/mutations/deprecated_account.py@@ -6,7 +6,7 @@ from ....checkout import AddressTypefrom ...account.enums import AddressTypeEnumfrom ...account.types import Address, AddressInput, Userfrom ...core.mutations import BaseMutation, ModelMutation-from ...core.utils.error_codes import AccountErrorCode+from ...core.utils.error_codes import AccountErrorCode, CommonErrorCodefrom .base import BaseCustomerCreate, UserAddressInputfrom .deprecated_staff import send_user_password_reset_email@@ -185,7 +185,7 @@ class CustomerPasswordReset(BaseMutation):{"email": ValidationError("User with this email doesn't exist",- code=AccountErrorCode.USER_DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/account/mutations/deprecated_staff.py b/saleor/graphql/account/mutations/deprecated_staff.pyindex 70dcc144fc..1780cd8b45 100644--- a/saleor/graphql/account/mutations/deprecated_staff.py+++ b/saleor/graphql/account/mutations/deprecated_staff.py@@ -7,7 +7,7 @@ from django.utils.http import urlsafe_base64_encodefrom ....account import emails, modelsfrom ...core.mutations import BaseMutation-from ...core.utils.error_codes import AccountErrorCode+from ...core.utils.error_codes import CommonErrorCodedef send_user_password_reset_email(user, site):@@ -42,7 +42,7 @@ class PasswordReset(BaseMutation):{"email": ValidationError("User with this email doesn't exist",- code=AccountErrorCode.USER_DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 57d129309c..f204e160dd 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -448,7 +448,7 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):{"checkout_id": ValidationError(f"Couldn't resolve to a node: {checkout_id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -552,7 +552,7 @@ class CheckoutShippingMethodUpdate(BaseMutation):{"checkout_id": ValidationError(f"Couldn't resolve to a node: {checkout_id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -714,7 +714,7 @@ class CheckoutUpdateVoucher(BaseMutation):{"voucher_code": ValidationError("Voucher with given code does not exist.",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.pyindex bfb82fdbe7..14c220316c 100644--- a/saleor/graphql/core/mutations.py+++ b/saleor/graphql/core/mutations.py@@ -152,7 +152,7 @@ class BaseMutation(graphene.Mutation):{field: ValidationError("Couldn't resolve to a node: %s" % node_id,- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/core/utils/__init__.py b/saleor/graphql/core/utils/__init__.pyindex 1b4549244e..4d240d2472 100644--- a/saleor/graphql/core/utils/__init__.py+++ b/saleor/graphql/core/utils/__init__.py@@ -53,7 +53,7 @@ def from_global_id_strict_type({field: ValidationError("Couldn't resolve to a node: %s" % global_id,- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)}) from excdiff --git a/saleor/graphql/core/utils/error_codes.py b/saleor/graphql/core/utils/error_codes.pyindex 07dc1fd5f3..fe4744fbf3 100644--- a/saleor/graphql/core/utils/error_codes.py+++ b/saleor/graphql/core/utils/error_codes.py@@ -53,7 +53,6 @@ class AccountErrorCode(Enum):INVALID_PHONE_NUMBER = "invalid_phone_number"INVALID_USER_TOKEN = "invalid_user_token"NOT_USERS_ADDRESS = "not_users_address"- USER_DOES_NOT_EXIST = "user_does_not_exist"class CheckoutErrorCode(Enum):@@ -93,13 +92,11 @@ class OrderErrorCode(Enum):ORDER_NO_SHIPPING_ADDRESS = "order_no_shipping_address"QUANTITY_LESS_THAN_ONE = "quantity_less_than_one"REFUND_MANUAL_PAYMENT = "refund_manual_payment"- VARIANT_DOES_NOT_EXIST = "variant_does_not_exist"VOID_INACTIVE_PAYMENT = "void_inactive_payment"class CommonErrorCode(Enum):CANNOT_FETCH_TAX_RATES = "cannot_fetch_tax_rates"- DOES_NOT_EXIST = "does_not_exist"GRAPHQL_ERROR = "graphql_error"INCORRECT_VALUE = "incorrect_value"INVALID_FILE_TYPE = "invalid_file_type"@@ -108,6 +105,7 @@ class CommonErrorCode(Enum):MISSING_VALUE = "missing_value"NON_BLANK_VALUE_REQUIRED = "non_blank_value_required"OBJECT_ALREADY_EXISTS = "object_already_exists"+ OBJECT_DOES_NOT_EXIST = "object_does_not_exist"PARTIAL_PAYMENT_NOT_ALLOWED = "partial_payment_not_allowed"PAYMENT_ERROR = "payment_error"POSITIVE_NUMBER_REQUIRED = "positive_number_required"diff --git a/saleor/graphql/giftcard/mutations.py b/saleor/graphql/giftcard/mutations.pyindex 556aa44496..bff22cb4f4 100644--- a/saleor/graphql/giftcard/mutations.py+++ b/saleor/graphql/giftcard/mutations.py@@ -11,7 +11,7 @@ from ...giftcard import modelsfrom ...giftcard.utils import activate_gift_card, deactivate_gift_cardfrom ..core.mutations import BaseMutation, ModelMutationfrom ..core.scalars import Decimal-from ..core.utils.error_codes import AccountErrorCode+from ..core.utils.error_codes import CommonErrorCodefrom .types import GiftCard@@ -64,7 +64,7 @@ class GiftCardCreate(ModelMutation):{"email": ValidationError("Customer with this email doesn't exist.",- code=AccountErrorCode.USER_DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/order/utils.py b/saleor/graphql/order/utils.pyindex 2febf77b9b..07b8c2fbfa 100644--- a/saleor/graphql/order/utils.py+++ b/saleor/graphql/order/utils.py@@ -1,6 +1,6 @@from django.core.exceptions import ValidationError-from ..core.utils.error_codes import OrderErrorCode+from ..core.utils.error_codes import CommonErrorCode, OrderErrorCodedef validate_total_quantity(order):@@ -41,7 +41,7 @@ def validate_order_lines(order):{"lines": ValidationError("Could not create orders with non-existing products.",- code=OrderErrorCode.VARIANT_DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.pyindex cdbc8ef85b..20fc79e6ce 100644--- a/saleor/graphql/product/mutations/attributes.py+++ b/saleor/graphql/product/mutations/attributes.py@@ -689,7 +689,7 @@ class ProductTypeReorderAttributes(BaseMutation):{"product_type_id": ValidationError((f"Couldn't resolve to a product type: {product_type_id}"),- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -710,7 +710,7 @@ class ProductTypeReorderAttributes(BaseMutation):{"moves": ValidationError(f"Couldn't resolve to an attribute: {move_info.id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -753,7 +753,7 @@ class AttributeReorderValues(BaseMutation):{"attribute_id": ValidationError(f"Couldn't resolve to an attribute: {attribute_id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -774,7 +774,7 @@ class AttributeReorderValues(BaseMutation):{"moves": ValidationError(f"Couldn't resolve to an attribute value: {move_info.id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex dc3b293e53..9b0007bc48 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -251,7 +251,7 @@ class CollectionReorderProducts(BaseMutation):{"collection_id": ValidationError(f"Couldn't resolve to a collection: {collection_id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})@@ -273,7 +273,7 @@ class CollectionReorderProducts(BaseMutation):{"moves": ValidationError(f"Couldn't resolve to a product: {move_info.product_id}",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex ebf8cb255e..52051465a5 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -1414,7 +1414,6 @@ enum ErrorCode {DELETE_STAFF_ACCOUNTDELETE_STUFF_ACCOUNTDELETE_SUPERUSER_ACCOUNT- DOES_NOT_EXISTEDIT_NON_DRAFT_ORDEREMPTYFULFILL_ORDER_LINE@@ -1458,6 +1457,7 @@ enum ErrorCode {NULLNULL_CHARACTERS_NOT_ALLOWEDOBJECT_ALREADY_EXISTS+ OBJECT_DOES_NOT_EXISTORDER_INVALID_SHIPPING_METHODORDER_NO_PAYMENTORDER_NO_SHIPPING_ADDRESS@@ -1484,9 +1484,7 @@ enum ErrorCode {UNIQUEUNIQUE_FOR_DATEUNKNOWN- USER_DOES_NOT_EXISTVALUE_ERROR- VARIANT_DOES_NOT_EXISTVARIANT_NO_DIGITAL_CONTENTVOID_INACTIVE_PAYMENTVOUCHER_NOT_APPLICABLEdiff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.pyindex d0a71bc0d9..1291d4ca03 100644--- a/saleor/graphql/shop/mutations.py+++ b/saleor/graphql/shop/mutations.py@@ -232,7 +232,7 @@ class AuthorizationKeyDelete(BaseMutation):{"key_type": ValidationError("Couldn't resolve authorization key",- code=CommonErrorCode.DOES_NOT_EXIST,+ code=CommonErrorCode.OBJECT_DOES_NOT_EXIST,)})diff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 14fdcbdbae..0e15b6bc62 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -26,7 +26,7 @@ from saleor.graphql.account.mutations.staff import ()from saleor.graphql.core.enums import PermissionEnumfrom saleor.graphql.core.utils import str_to_enum-from saleor.graphql.core.utils.error_codes import AccountErrorCode+from saleor.graphql.core.utils.error_codes import AccountErrorCode, CommonErrorCodefrom saleor.order.models import FulfillmentStatus, Orderfrom tests.api.utils import get_graphql_contentfrom tests.utils import create_image@@ -1656,7 +1656,7 @@ def test_set_password_invalid_email(user_api_client):errors = content["data"]["setPassword"]["errors"]assert len(errors) == 1assert errors[0]["field"] == "email"- assert errors[0]["code"] == AccountErrorCode.USER_DOES_NOT_EXIST.name+ assert errors[0]["code"] == CommonErrorCode.OBJECT_DOES_NOT_EXIST.namedef test_set_password_invalid_password(user_api_client, customer_user, settings):@@ -1736,7 +1736,7 @@ def test_password_reset_email_non_existing_user({"field": "email","message": "User with this email doesn't exist",- "code": AccountErrorCode.USER_DOES_NOT_EXIST.name,+ "code": CommonErrorCode.OBJECT_DOES_NOT_EXIST.name,}]send_password_reset_mock.assert_not_called()diff --git a/tests/api/test_base_mutation.py b/tests/api/test_base_mutation.pyindex 7f1679b77a..3493716e30 100644--- a/tests/api/test_base_mutation.py+++ b/tests/api/test_base_mutation.py@@ -84,7 +84,7 @@ def test_user_error_nonexistent_id(schema_context):assert user_errorsassert user_errors[0]["field"] == "productId"assert user_errors[0]["message"] == "Couldn't resolve to a node"- assert user_errors[0]["code"] == CommonErrorCode.DOES_NOT_EXIST.name+ assert user_errors[0]["code"] == CommonErrorCode.OBJECT_DOES_NOT_EXIST.namedef test_user_error_id_of_different_type(product, schema_context):diff --git a/tests/api/test_gift_card.py b/tests/api/test_gift_card.pyindex de5e63bcc1..b876d10931 100644--- a/tests/api/test_gift_card.py+++ b/tests/api/test_gift_card.py@@ -2,7 +2,7 @@ from datetime import dateimport graphene-from saleor.graphql.core.utils.error_codes import AccountErrorCode, CommonErrorCode+from saleor.graphql.core.utils.error_codes import CommonErrorCodefrom tests.api.utils import get_graphql_contentfrom .utils import assert_no_permission@@ -351,7 +351,7 @@ def test_create_gift_card_with_incorrect_user_email(assert len(errors) == 1assert errors[0]["field"] == "email"assert errors[0]["message"] == "Customer with this email doesn't exist."- assert errors[0]["code"] == AccountErrorCode.USER_DOES_NOT_EXIST.name+ assert errors[0]["code"] == CommonErrorCode.OBJECT_DOES_NOT_EXIST.namedef test_create_gift_card_without_premissions(staff_api_client):