passbolt/passbolt_api · error · CustomValidationException
The rbacs could not be saved.
Error message
The rbacs could not be saved.
What it means
Thrown by CreateRbacsOnRoleCreateListener::createRbacsOnRoleCreate() when saveManyOrFail on the RBAC entities fails with a PersistenceFailedException, re-raised as a CustomValidationException carrying the entity errors. It means one or more of the per-role default RBAC rows violated model/validation rules.
Solutions
- Read the CustomValidationException's errors payload to identify which rbac entities/fields failed.
- Check the rbacs table for duplicate rows for the new role and clean them up.
- Re-run migrations so the rbacs schema and default rows are consistent.
- Retry role creation after fixing the conflicting data.
Defensive patterns
Strategy: try-catch
Validate before calling
foreach ($entities as $entity) {
if ($entity->getErrors()) {
throw new InvalidArgumentException('Invalid rbac entity: ' . json_encode($entity->getErrors()));
}
} Try / catch
try {
$rbacsTable->saveManyOrFail($entities);
} catch (PersistenceFailedException $e) {
$errors = $e->getEntity()->getErrors();
// inspect and repair conflicting rbacs rows
} Prevention
- Keep the rbacs table free of duplicate rows (uniqueness on role_id + control_function).
- Run all migrations after upgrades.
- Avoid creating roles concurrently with rbacs regeneration jobs.
- Log entity errors at save time to diagnose conflicts quickly.
When it happens
Trigger: Role-created event fires and the generated RBAC entities fail validation during save (e.g. invalid control_function, duplicate uniqueness constraint, missing required field).
Common situations: Corrupted or partially migrated rbacs table causing uniqueness conflicts, plugin registering UI actions whose names conflict with existing rbacs rows, or database state left inconsistent after a failed upgrade.
Related errors
- The request data is invalid: id invalid.
- " " is not a valid search filter.
- " " is not a valid search filter. It is not a UTF8 string.
- " " is not a valid search filter. It should be between 1…
- " " is not a valid user filter.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/527d7ecddb859fb4.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Rbacs/src/Event/CreateRbacsOnRoleCreateListener.php:103
['accessibleFields' => [
'role_id' => true,
'control_function' => true,
'foreign_model' => true,
'foreign_id' => true,
'created' => true,
'modified' => true,
'created_by' => true,
'modified_by' => true,
]]
);
}
try {
$rbacsTable->saveManyOrFail($entities);
} catch (PersistenceFailedException $e) {
$errors = $e->getEntity()->getErrors();
throw new CustomValidationException(
__('The rbacs could not be saved.'),
$errors
);
} catch (Exception $e) {
throw new InternalErrorException(__('Could not save the rbacs, please try again later.'), null, $e);
}
}
}
View on GitHub (pinned to 31c1bbc10f)