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

  1. Read the CustomValidationException's errors payload to identify which rbac entities/fields failed.
  2. Check the rbacs table for duplicate rows for the new role and clean them up.
  3. Re-run migrations so the rbacs schema and default rows are consistent.
  4. 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

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


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)