{"record":{"id":"cc87113d0bbc0c88","repo":"passbolt/passbolt_api","slug":"could-not-validate-folder-data","errorCode":null,"errorMessage":"Could not validate folder data.","messagePattern":"Could not validate folder data\\.","errorType":"validation","errorClass":"App\\Error\\Exception\\ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Folders/src/Service/Folders/FoldersCreateService.php","lineNumber":163,"sourceCode":"            'created_by' => true,\n            'modified_by' => true,\n        ]);\n\n        return $this->foldersTable->newEntity($data, $options);\n    }\n\n    /**\n     * Handle folder validation errors.\n     *\n     * @param \\Passbolt\\Folders\\Model\\Entity\\Folder $folder The folder\n     * @return void\n     * @throws \\App\\Error\\Exception\\ValidationException If the provided data does not validate.\n     */\n    private function handleValidationErrors(Folder $folder): void\n    {\n        $errors = $folder->getErrors();\n        if (!empty($errors)) {\n            throw new ValidationException(__('Could not validate folder data.'), $folder, $this->foldersTable);\n        }\n    }\n\n    /**\n     * Create the user permission for the created folder.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac The current user\n     * @param \\Passbolt\\Folders\\Model\\Entity\\Folder $folder The folder\n     * @return void\n     */\n    private function createPermission(UserAccessControl $uac, Folder $folder): void\n    {\n        $userId = $uac->getId();\n        $permissionData = [\n            'aco' => PermissionsTable::FOLDER_ACO,\n            'aco_foreign_key' => $folder->id,\n            'aro' => PermissionsTable::USER_ARO,\n            'aro_foreign_key' => $userId,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Service/Folders/FoldersCreateService.php#L145-L181","documentation":"Thrown by FoldersCreateService::handleValidationErrors() when the Folder entity built for creation carries validation errors. It means the folder creation request data (name, parent id, etc.) failed the Folders table validation rules.","triggerScenarios":"POST /folders with a name that is empty/too long, an invalid folder_parent_id (non-UUID), or personal-space violations; calling createFolder/createFolderRelation with data that fails entity rules.","commonSituations":"API clients sending missing or blank 'name'; nesting a folder under a nonexistent or inaccessible parent; passing personal:true with a folder_parent_id the user cannot access.","solutions":["Read the errors array on the ValidationException and correct the offending field in the request payload.","Ensure 'name' is a non-empty string within length limits and ids are valid UUIDs.","Verify the parent folder exists and the user has update permission on it before creating a child.","Catch ValidationException in the controller and return the error details to the client (the controller layer typically does this already)."],"exampleFix":"// before\nPOST /folders {\"folder_parent_id\":\"not-a-uuid\"}\n// after\nPOST /folders {\"name\":\"Projects\",\"folder_parent_id\":\"e3f0a2b4-1c5d-4f8a-9b2e-7d6c1a0f5e33\"}","handlingStrategy":"validation","validationCode":"$errors = [];\nif (empty($data['name']) || strlen($data['name']) > 256) { $errors[] = 'name required (<=256 chars)'; }\nif (isset($data['folder_parent_id']) && !Uuid::isValid($data['folder_parent_id'])) { $errors[] = 'invalid folder_parent_id'; }\nif ($errors) { throw new InvalidArgumentException(implode('; ', $errors)); }","typeGuard":"$isValidFolderPayload = fn(array $data): bool => isset($data['name']) && is_string($data['name']) && trim($data['name']) !== '' && (!isset($data['folder_parent_id']) || Uuid::isValid($data['folder_parent_id']));","tryCatchPattern":"try { $service->create($uac, $data); } catch (ValidationException $e) { return $this->respondValidationError($e->getErrors()); }","preventionTips":["Require a non-empty name in API clients","Validate parent folder access (update permission) before creating children","Use UUID validation on all ids client-side before submitting"],"tags":["validation","folders","api"],"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"}