[permissions V2] Throw when objectPermissions not found in datasource (#12325)
I encountered a bug where I was missing permissions while calling searchResolver because the repository from `twentyORMManager.getRepository` was missing permissions itself. The repository was returned from the cached repositories map using a repository key feature the roleId, the rolesVersion and featureFlagMapVersion. I was not able to reproduce but this error should not go unnoticed: we always expect to find objectPermissions for every roleId in the datasource now. I was not able to understand what happened for now but I think throwing the error will help keeping an eye on it
This commit is contained in:
@ -30,6 +30,7 @@ export enum PermissionsExceptionCode {
|
||||
INVALID_SETTING = 'INVALID_SETTING',
|
||||
ROLE_NOT_EDITABLE = 'ROLE_NOT_EDITABLE',
|
||||
DEFAULT_ROLE_CANNOT_BE_DELETED = 'DEFAULT_ROLE_CANNOT_BE_DELETED',
|
||||
NO_PERMISSIONS_FOUND_IN_DATASOURCE = 'NO_PERMISSIONS_FOUND_IN_DATASOURCE',
|
||||
}
|
||||
|
||||
export enum PermissionsExceptionMessage {
|
||||
@ -54,4 +55,5 @@ export enum PermissionsExceptionMessage {
|
||||
INVALID_SETTING = 'Invalid permission setting (unknown value)',
|
||||
ROLE_NOT_EDITABLE = 'Role is not editable',
|
||||
DEFAULT_ROLE_CANNOT_BE_DELETED = 'Default role cannot be deleted',
|
||||
NO_PERMISSIONS_FOUND_IN_DATASOURCE = 'No permissions found in datasource',
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ export const permissionGraphqlApiExceptionHandler = (
|
||||
case PermissionsExceptionCode.UNKNOWN_OPERATION_NAME:
|
||||
case PermissionsExceptionCode.UNKNOWN_REQUIRED_PERMISSION:
|
||||
case PermissionsExceptionCode.NO_ROLE_FOUND_FOR_USER_WORKSPACE:
|
||||
case PermissionsExceptionCode.NO_PERMISSIONS_FOUND_IN_DATASOURCE:
|
||||
throw error;
|
||||
default: {
|
||||
const _exhaustiveCheck: never = error.code;
|
||||
|
||||
Reference in New Issue
Block a user