{"record":{"id":"dba79ff5388f7dbf","repo":"passbolt/passbolt_api","slug":"could-not-validate-move-data","errorCode":null,"errorMessage":"Could not validate move data.","messagePattern":"Could not validate move data\\.","errorType":"validation","errorClass":"App\\Error\\Exception\\CustomValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Folders/src/Controller/FoldersRelations/FoldersRelationsMoveController.php","lineNumber":95,"sourceCode":"            $errors = ['folder_parent_id' => ['uuid' => __('The folder parent identifier should be a valid UUID.')]];\n            $this->handleValidationErrors($errors);\n        }\n\n        return $folderParentId;\n    }\n\n    /**\n     * Handle folder validation errors.\n     *\n     * @param array $errors The errors\n     * @return void\n     * @throws \\App\\Error\\Exception\\CustomValidationException If errors\n     */\n    private function handleValidationErrors(array $errors)\n    {\n        if (!empty($errors)) {\n            $foldersRelationsTable = TableRegistry::getTableLocator()->get('Passbolt/Folders.FoldersRelations');\n            throw new CustomValidationException(__('Could not validate move data.'), $errors, $foldersRelationsTable);\n        }\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":99,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Controller/FoldersRelations/FoldersRelationsMoveController.php#L77-L99","documentation":"handleValidationErrors() collects validation errors gathered while resolving/validating the folder parent id in getAndValidateFolderParentId() and throws a CustomValidationException with the message 'Could not validate move data.' plus the error details attached to the Passbolt/Folders.FoldersRelations table. It signals the move payload failed domain validation.","triggerScenarios":"Calling the folder move endpoint where the parent id checks fail: `folder_parent_id` not a valid UUID, equal to the folder being moved (moving folder into itself), missing, or referencing an invalid/non-existent parent — any non-empty $errors array from getAndValidateFolderParentId.","commonSituations":"Client sending folder_parent_id pointing to the same folder, sending a parent id of a folder the user has no access to (surfaced as validation error), or omitting folder_parent_id when it is required.","solutions":["Inspect the errors collection in the exception response (fields under the FoldersRelations table) to see which field failed.","Ensure `folder_parent_id` is a valid UUID of an existing folder the user can use, or null (root) if moving to root is intended.","Never set folder_parent_id to the id of the folder being moved (no self-parenting)."],"exampleFix":"// before\nmove(folderId, 'Folder', childId, {folder_parent_id: folderId}); // self-parent\n// after\nconst parentId = folderId === targetParentId ? null : targetParentId;\nmove(folderId, 'Folder', childId, {folder_parent_id: parentId});","handlingStrategy":"try-catch","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (folderParentId !== null && (folderParentId === folderId || !UUID_RE.test(folderParentId))) {\n  throw new Error('folder_parent_id must be null or a UUID different from the folder being moved');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await move(folderId, foreignModel, foreignId, {folder_parent_id: parentId});\n} catch (e) {\n  if (e.response?.status === 400 && /Could not validate move data/.test(e.response?.data?.message ?? '')) {\n    const errors = e.response?.data?.errors ?? {};\n    // surface per-field errors from the FoldersRelations table to the user\n  }\n  throw e;\n}","preventionTips":["Never send the moved folder's own id as folder_parent_id (no self-parenting).","Verify the target parent folder exists and is accessible before moving.","Parse and display the per-field errors object returned with the exception instead of ignoring it.","Add UI-side checks preventing dropping a folder into itself or its descendants."],"tags":["validation","folders","move-operation"],"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"}