Skip to content

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

Imporving an error message(#13334) (#13652)

Rafał Krupińskie1917f6f0a13
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15f5f4aa72..942406477e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,8 @@ in 3.17. Use `PaymentSettings.defaultTransactionFlowStrategy` instead.
### Other changes
- Fix error in variant available stock calculation - 13593 by @awaisdar001
+- Change error message when denying a permission - #13334 by @rafiwts
+
# 3.15.0 [Unreleased]
### Breaking changes
diff --git a/saleor/core/exceptions.py b/saleor/core/exceptions.py
index d8b10595c4..b35aab01d2 100644
--- a/saleor/core/exceptions.py
+++ b/saleor/core/exceptions.py
@@ -63,7 +63,8 @@ class PermissionDenied(Exception):
if permissions:
permission_list = ", ".join(p.name for p in permissions)
message = (
- f"You need one of the following permissions: {permission_list}"
+ "To access this path, you need one of the "
+ f"following permissions: {permission_list}"
)
else:
message = "You do not have permission to perform this action"
diff --git a/saleor/graphql/core/tests/test_base_mutation.py b/saleor/graphql/core/tests/test_base_mutation.py
index 7cce01152e..b2a3557785 100644
--- a/saleor/graphql/core/tests/test_base_mutation.py
+++ b/saleor/graphql/core/tests/test_base_mutation.py
@@ -362,7 +362,10 @@ def test_mutation_calls_plugin_perform_mutation_after_permission_checks(
mutation_query, variables=variables, context_value=schema_context
)
assert len(result.errors) == 1, result.to_dict()
- assert "You need one of the following permissions" in result.errors[0].message
+ assert (
+ "To access this path, you need one of the following permissions"
+ in result.errors[0].message
+ )
# When permission is not missing, the execution of the plugin should happen
staff_user.user_permissions.set([permission_manage_products])