diff --git a/apps/authentication/backend/infra/permission/permission_handler.py b/apps/authentication/backend/infra/permission/permission_handler.py index 4076185..9983396 100644 --- a/apps/authentication/backend/infra/permission/permission_handler.py +++ b/apps/authentication/backend/infra/permission/permission_handler.py @@ -80,7 +80,7 @@ class PermissionHandler: # Delete the old document with the original ID try: old_doc = await PermissionDoc.get(old_id) - if old_doc: + if (str(old_id) != custom_permission_id) and old_doc: await old_doc.delete() except Exception as e: # Log the error but don't fail the operation diff --git a/apps/authentication/backend/infra/permission/role_handler.py b/apps/authentication/backend/infra/permission/role_handler.py index d096d7e..c1dd796 100644 --- a/apps/authentication/backend/infra/permission/role_handler.py +++ b/apps/authentication/backend/infra/permission/role_handler.py @@ -84,7 +84,7 @@ class RoleHandler: # Delete the old document with the original ID try: old_doc = await RoleDoc.get(old_id) - if old_doc: + if (str(old_id) != custom_role_id) and old_doc: await old_doc.delete() except Exception as e: # Log the error but don't fail the operation @@ -122,7 +122,7 @@ class RoleHandler: raise RequestValidationError("role_id and permission_ids are required.") doc = await RoleDoc.get(role_id) if not doc: - raise RequestValidationError("Role not found.") + raise RequestValidationError(f"Role not found. {role_id}") # Validate that all permission_ids exist in the permission collection for permission_id in permission_ids: