31 RoleNotFound: Role not found
MongoDB의미
참조한 역할이 MongoDB에 정의되어 있지 않다. 사용자에게 역할을 부여하거나, 역할을 갱신하거나, 역할의 권한을 조회할 때 존재하지 않는 역할 이름을 사용했다.
원인
grantRolesToUser/createUser에서 철자가 틀렸거나 생성된 적 없는 역할 이름을 사용했거나, 잘못된 데이터베이스에서 역할을 찾았거나(역할은 특정 DB에 속한다), 아직 createRole로 정의하지 않은 사용자 정의(내장이 아닌) 역할을 사용한 경우다.
해결 방법
역할 이름과 역할이 속한 데이터베이스를 확인한다. 기존 역할 목록: db.getRoles({showBuiltinRoles: false}) 또는 모든 DB를 대상으로 하는 해당 관리 쿼리. 사용자 정의 역할이 없으면 먼저 생성한다: db.createRole({role:'reader', privileges:[...], roles:[]}). 부여 시 올바른 db를 지정한다: db.grantRolesToUser('app_user', [{role:'reader', db:'app'}]).
같은 데이터베이스의 다른 항목
- 9FailedToParse
- 134ReadConcernMajorityNotAvailableYet
- 202NetworkInterfaceExceededTimeLimit
- 263 OperationNotSupportedInTransactionOperation not supported inside a multi-document transaction (multi-document 트랜잭션 내에서 지원되지 않는 작업)
- 20 IllegalOperationIllegal operation
- 48 NamespaceExistsNamespace (collection) already exists
- 11601 InterruptedOperation was interrupted