Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add more meaningfull error code to RetryInstallApp
Maciej Korycinskid8258d06440e
diff --git a/saleor/app/error_codes.py b/saleor/app/error_codes.pyindex 71b473fb61..1d5e295ef2 100644--- a/saleor/app/error_codes.py+++ b/saleor/app/error_codes.py@@ -5,6 +5,7 @@ class AppErrorCode(Enum):FORBIDDEN = "forbidden"GRAPHQL_ERROR = "graphql_error"INVALID = "invalid"+ INVALID_STATUS = "invalid_status"NOT_FOUND = "not_found"REQUIRED = "required"UNIQUE = "unique"diff --git a/saleor/graphql/app/mutations.py b/saleor/graphql/app/mutations.pyindex 51f728879e..0b09cd30f0 100644--- a/saleor/graphql/app/mutations.py+++ b/saleor/graphql/app/mutations.py@@ -272,7 +272,7 @@ class AppRetryInstall(ModelMutation):if instance.status != JobStatus.FAILED:msg = "Cannot retry installation with different status than failed."- code = AppErrorCode.FORBIDDEN.value+ code = AppErrorCode.INVALID_STATUS.valueraise ValidationError({"id": ValidationError(msg, code=code)})@classmethoddiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 9ab328da5b..a9e1fea065 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -254,6 +254,7 @@ enum AppErrorCode {FORBIDDENGRAPHQL_ERRORINVALID+ INVALID_STATUSNOT_FOUNDREQUIREDUNIQUEdiff --git a/tests/api/app/mutations/test_app_retry_install.py b/tests/api/app/mutations/test_app_retry_install.pyindex d400ed7a73..bc76e45e0b 100644--- a/tests/api/app/mutations/test_app_retry_install.py+++ b/tests/api/app/mutations/test_app_retry_install.py@@ -180,6 +180,6 @@ def test_cannot_retry_installation_if_status_is_different_than_failed(assert not app_installation_dataassert len(app_installation_errors) == 1assert app_installation_errors[0]["field"] == "id"- assert app_installation_errors[0]["code"] == AppErrorCode.FORBIDDEN.name+ assert app_installation_errors[0]["code"] == AppErrorCode.INVALID_STATUS.nameassert not mocked_task.called