Unable to delete a user role when a user has multiple roles assigned

Using Strapi version 4.8.

On the schema.json of ‘users-permissions’ plugin at path src/extensions/users-permissions/content-types/user I modified the user-role relation to ‘manyToMany’:

"role": {
  "type": "relation",
  "relation": "manyToMany",
  "target": "plugin::users-permissions.role",
  "inversedBy": "users",
  "configurable": false

As seen on an other topic: Users and Permissions Plugin: How to assign multiple roles to single end-user

That worked as expected.

But now I got an error when I try to delete one role on a user that already has multiple roles assigned. I am not trying to delete all the roles that one user has, just if it has 3 roles delete one or two roles but always leave the user with at least one role.

The error thrown by the Strapi BackOffice is:

  "data": null,
  "error": {
    "status": 400,
    "name": "ValidationError",
    "message": "Cannot remove role",
    "details": {
      "errors": [
          "path": [
          "message": "Cannot remove role",
          "name": "ValidationError"

Is there any solution? On newer versions it has been fixed?


In 4.20.5, the path to the file that defines the user<>role relation is my-project/node_modules/@strapi/plugin-users-permissions/server/content-types/permission/index.js. This file comes as a dependency, i.e. developers are not supposed to change it in order to enable multiple roles for end users.

It appears there simply is no concept of multiple custom roles for end users. One user can only have up to one custom role.