Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add more meaningfull error code to RetryInstallApp

Maciej Korycinskid8258d06440e
diff --git a/saleor/app/error_codes.py b/saleor/app/error_codes.py
index 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.py
index 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.value
raise ValidationError({"id": ValidationError(msg, code=code)})
@classmethod
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 9ab328da5b..a9e1fea065 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -254,6 +254,7 @@ enum AppErrorCode {
FORBIDDEN
GRAPHQL_ERROR
INVALID
+ INVALID_STATUS
NOT_FOUND
REQUIRED
UNIQUE
diff --git a/tests/api/app/mutations/test_app_retry_install.py b/tests/api/app/mutations/test_app_retry_install.py
index 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_data
assert len(app_installation_errors) == 1
assert app_installation_errors[0]["field"] == "id"
- assert app_installation_errors[0]["code"] == AppErrorCode.FORBIDDEN.name
+ assert app_installation_errors[0]["code"] == AppErrorCode.INVALID_STATUS.name
assert not mocked_task.called