passbolt/passbolt_api · warning
$message
Error message
$message
What it means
SyncCommandTrait::displayValidationError recursively prints entity validation errors to the console. When a field's error value is itself an array (nested error messages), it recurses via $this->displayValidationError($error, $io); passing the wrong variable means nested errors are re-printed from the top level, so the message displayed is an arbitrary $message from the loop rather than the intended field-specific text. It is a diagnostic output helper, not a thrown exception.
Solutions
- Fix the recursion to pass the nested array, not $error: $this->displayValidationError($message, $io).
- Run with --verbose to see the full entry and inspect the actual validation errors on the entity.
- Fix the underlying directory data (invalid emails, duplicates) so entities validate.
Example fix
// before $this->displayValidationError($error, $io); // after $this->displayValidationError($message, $io);
Defensive patterns
Strategy: validation
Validate before calling
// Before syncing, validate entries and surface errors properly
foreach ($users as $user) {
if ($user->getErrors()) {
foreach ($user->getErrors() as $field => $errs) {
$io->err($field . ': ' . json_encode($errs));
}
}
} Type guard
if (is_array($message)) {
$this->displayValidationError($message, $io); // recurse on the nested array
} else {
$io->err(...);
} Prevention
- Validate directory data before running sync
- Use --verbose to inspect per-entry errors
- Keep attribute mapping aligned with passbolt entity rules
When it happens
Trigger: Running `bin/cake passbolt directory_sync` when synced LDAP users/groups fail entity validation and any validation error has nested array messages (e.g. rule-based errors like 'user_exists' returning arrays).
Common situations: Directory entries with invalid emails, duplicate users, or custom validation rules that nest error arrays; developers debugging directory sync see mangled or duplicated output.
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
- group(s) returned by your directory are invalid and will be…
- users returned by your directory are invalid and will be…
- $exception->getMessage()
- $msg
- The record model is not valid.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/2d7890ca513ec72b.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/DirectorySync/src/Command/SyncCommandTrait.php:144
}
/**
* Display the entity validation errors
*
* @param array $errors validation errors
* @param \Cake\Console\ConsoleIo $io Console IO.
* @return void
*/
protected function displayValidationError(array $errors, ConsoleIo $io): void
{
foreach ($errors as $fieldname => $error) {
foreach ($error as $message) {
if (is_array($message)) {
$this->displayValidationError($error, $io);
break;
} else {
$message = str_pad('', $this->pad) . ucfirst(str_replace('_', ' ', $fieldname)) . ': ' . $message;
$io->err($message);
}
}
}
}
}
View on GitHub (pinned to 31c1bbc10f)