{"record":{"id":"2d7890ca513ec72b","repo":"passbolt/passbolt_api","slug":"message","errorCode":null,"errorMessage":"$message","messagePattern":"\\$message","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/PassboltEe/DirectorySync/src/Command/SyncCommandTrait.php","lineNumber":144,"sourceCode":"    }\n\n    /**\n     * Display the entity validation errors\n     *\n     * @param array $errors validation errors\n     * @param \\Cake\\Console\\ConsoleIo $io Console IO.\n     * @return void\n     */\n    protected function displayValidationError(array $errors, ConsoleIo $io): void\n    {\n        foreach ($errors as $fieldname => $error) {\n            foreach ($error as $message) {\n                if (is_array($message)) {\n                    $this->displayValidationError($error, $io);\n                    break;\n                } else {\n                    $message = str_pad('', $this->pad) . ucfirst(str_replace('_', ' ', $fieldname)) . ': ' . $message;\n                    $io->err($message);\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":126,"sourceCodeEnd":150,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Command/SyncCommandTrait.php#L126-L150","documentation":"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.","triggerScenarios":"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).","commonSituations":"Directory entries with invalid emails, duplicate users, or custom validation rules that nest error arrays; developers debugging directory sync see mangled or duplicated output.","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."],"exampleFix":"// before\n$this->displayValidationError($error, $io);\n// after\n$this->displayValidationError($message, $io);","handlingStrategy":"validation","validationCode":"// Before syncing, validate entries and surface errors properly\nforeach ($users as $user) {\n    if ($user->getErrors()) {\n        foreach ($user->getErrors() as $field => $errs) {\n            $io->err($field . ': ' . json_encode($errs));\n        }\n    }\n}","typeGuard":"if (is_array($message)) {\n    $this->displayValidationError($message, $io); // recurse on the nested array\n} else {\n    $io->err(...);\n}","tryCatchPattern":null,"preventionTips":["Validate directory data before running sync","Use --verbose to inspect per-entry errors","Keep attribute mapping aligned with passbolt entity rules"],"tags":["cli","console-output","ldap","directory-sync","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}