passbolt/passbolt_api · error · ValidationException
Could not validate action data.
Error message
Could not validate action data.
What it means
ActionsTable::create() throws this ValidationException when the Action entity built via buildEntity() fails its validation rules before any save is attempted. It means the supplied action data (e.g. name) violates the table's validation ruleset.
Solutions
- Inspect $action->getErrors() (included in the ValidationException) to see which field failed.
- Ensure the action name passed to findOrCreateAction()/create() is a non-empty string within the column length limit.
- Check that the action context (context/name) matches what the validation rules expect.
- Add a rule to the validation validator if legitimate data is being rejected by an overly strict rule.
Example fix
// before
$this->getService(ActionLogsService::class)->create(...);
// after
// ensure action name is valid before reaching the table
if (!is_string($name) || $name === '') {
throw new BadRequestException('Action name must be a non-empty string.');
} Defensive patterns
Strategy: validation
Validate before calling
if (!is_string($name) || trim($name) === '') { throw new \InvalidArgumentException('Action name must be a non-empty string'); } Type guard
function isValidActionName(mixed $name): bool { return is_string($name) && trim($name) !== '' && mb_strlen($name) <= 255; } Try / catch
try { $action = $actionsTable->create($data); } catch (ValidationException $e) { $errors = $e->getEntity()->getErrors(); // inspect and correct payload
} Prevention
- Use findOrCreateAction() rather than raw create() for action logging.
- Log validation errors on first occurrence to catch regressions early.
- Keep action name constants centralized to avoid drift.
- Write tests asserting your action payloads validate.
When it happens
Trigger: findOrCreateAction() receives an action name that is empty, exceeds the column length, or has an invalid type, so buildEntity() produces an entity with errors immediately.
Common situations: Plugin code logging actions with a null or '' name; action names longer than the varchar limit after a rename; passing non-scalar data (array/object) where a string name is expected; locale/encoding issues with very long translated action strings.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not validate entity history data.
- Could not validate group data.
- Could not validate permission data.
- Could not validate permission history data.
- " " is not a valid search filter.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/318335b408131ff6.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Log/src/Model/Table/ActionsTable.php:127
* Create a new action.
*
* @param string $id action id
* @param string $name name of the action
* @return \Passbolt\Log\Model\Entity\Action
* @throws \App\Error\Exception\ValidationException
* @throws \Cake\Http\Exception\InternalErrorException
*/
public function create(string $id, string $name): Action
{
$data = [
'id' => $id,
'name' => $name,
];
// Check validation rules.
$action = $this->buildEntity($data);
if ($action->getErrors()) {
throw new ValidationException(__('Could not validate action data.', true), $action, $this);
}
/** @var \Passbolt\Log\Model\Entity\Action $actionSaved */
$actionSaved = $this->save($action);
// Check for validation errors.
if ($action->getErrors()) {
throw new ValidationException(__('Could not validate action data.'), $action, $this);
}
// Check for errors while saving.
if (!$actionSaved) {
throw new InternalErrorException('Could not save the action.');
}
return $actionSaved;
}
View on GitHub (pinned to 31c1bbc10f)