{"record":{"id":"27f660a84a6e4cdf","repo":"passbolt/passbolt_api","slug":"could-not-validate-folder-data-foldersshareservice","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/FoldersShareService.php","lineNumber":214,"sourceCode":"            $folder->setError('permissions', $e->getErrors());\n            $this->handleValidationErrors($folder);\n        }\n\n        return $entitiesChanges;\n    }\n\n    /**\n     * Handle folder validation errors.\n     *\n     * @param \\Passbolt\\Folders\\Model\\Entity\\Folder $folder The target 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     * Move content of the folder which was self organized without sufficient permission (<UPDATE) to move it into\n     * a shared folder to the root of the operator.\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac The operator\n     * @param \\Passbolt\\Folders\\Model\\Entity\\Folder $folder The target shared folder\n     * @return void\n     */\n    private function moveSelfOrganizedContentWithInsufficientPermissionToRoot(\n        UserAccessControl $uac,\n        Folder $folder\n    ): void {\n        /** @var array<\\Passbolt\\Folders\\Model\\Entity\\FoldersRelation> $personalItems */\n        $personalItems = $this->foldersRelationsTable\n            ->findByUserIdAndFolderParentId($uac->getId(), $folder->id)","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Service/Folders/FoldersShareService.php#L196-L232","documentation":"A ValidationException raised by FoldersShareService::handleValidationErrors when the folder entity fails model validation after a permissions update during share. The service applies permission changes through the FoldersTable, and if getErrors() returns non-empty validation errors on the folder entity, it wraps them in this exception along with the entity and table for inspection.","triggerScenarios":"POST /folders/{id}/share with permission payloads that produce entity-level validation errors during the update (e.g. invalid permission type, invalid aro/aco identifiers, changes that break folder entity rules), or associated permission entities failing save validation.","commonSituations":"Automated API clients posting malformed permission payloads (wrong permission type constants, non-UUID aro foreign keys), duplicate permissions for the same user on the folder, or permission rows referencing deleted users/groups.","solutions":["Read the validation errors attached to the 400 response body (errors field) — they pinpoint the failing field on the folder/permission entities.","Ensure each permission payload contains a valid type (1=READ, 7=UPDATE, 15=OWNER for folders) and a valid existing user/group id in aro.","Remove duplicate permission entries for the same aro on the folder; a user should appear once per folder.","Confirm the target users/groups still exist and are not deleted before sharing."],"exampleFix":"// before\n{\"permissions\":[{\"aro\":{\"id\":\"not-a-uuid\"},\"type\":99}]}\n// after\n{\"permissions\":[{\"aro\":{\"id\":\"8e3874ae-4b40-590b-b236-2c2648d88a3b\"},\"type\":7}]}","handlingStrategy":"validation","validationCode":"function validateSharePayload(permissions) {\n  const VALID = new Set([1, 7, 15]);\n  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n  return permissions.every(p =>\n    VALID.has(p.type) && UUID.test(p.aro?.id ?? '')\n  );\n}","typeGuard":null,"tryCatchPattern":"try {\n  await foldersApi.share(folderId, permissions);\n} catch (e) {\n  if (e.response?.status === 400 && e.response.data?.errors) {\n    console.error('Validation errors:', e.response.data.errors);\n  }\n  throw e;\n}","preventionTips":["Validate permission types against the enum (1=READ, 7=UPDATE, 15=OWNER) before sending.","Ensure aro ids are valid UUIDs of existing, non-deleted users/groups.","Never send duplicate permissions for the same aro on one folder.","Log and surface the per-field errors returned in the 400 body."],"tags":["validation","folders","sharing","entity-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"}