31 RoleNotFound: Role not found
MongoDBWhat does it mean?
The referenced role is not defined in MongoDB. A nonexistent role name was used while granting a role to a user, updating a role or querying a role's privileges.
Why does it happen?
A misspelled or never-created role name in grantRolesToUser/createUser; looking up the role in the wrong database (roles are bound to a specific DB); or a custom (non-built-in) role that has not yet been defined with createRole.
How to fix it
Verify the role name and the database it belongs to. List existing roles: db.getRoles({showBuiltinRoles: false}) or the corresponding admin query across all DBs. If the custom role does not exist, create it first: db.createRole({role:'reader', privileges:[...], roles:[]}). Specify the correct db when granting: db.grantRolesToUser('app_user', [{role:'reader', db:'app'}]).
More from this engine
- 9FailedToParse
- 134ReadConcernMajorityNotAvailableYet
- 202NetworkInterfaceExceededTimeLimit
- 263 OperationNotSupportedInTransactionOperation not supported inside a multi-document transaction
- 20 IllegalOperationIllegal operation
- 48 NamespaceExistsNamespace (collection) already exists
- 11601 InterruptedOperation was interrupted