{"record":{"id":"5903ba1b59f0e97a","repo":"passbolt/passbolt_api","slug":"could-not-validate-folder-data-foldersupdateservice","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/FoldersUpdateService.php","lineNumber":174,"sourceCode":"            'modified_by' => true,\n            'name' => true, // also required for v5 to clear out field\n        ]);\n\n        return $this->foldersTable->patchEntity($folder, $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","sourceCodeStart":156,"sourceCodeEnd":178,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Service/Folders/FoldersUpdateService.php#L156-L178","documentation":"A ValidationException raised by FoldersUpdateService::handleValidationErrors when the folder entity has validation errors after attempting to update folder metadata (name, personal flag, etc.). The entity's getErrors() is non-empty, so the service throws with the entity and FoldersTable attached so clients receive the per-field error details.","triggerScenarios":"PUT /folders/{folderId} (FoldersUpdateService::updateFolderMeta) with data failing FoldersTable rules: empty name, name exceeding length limits, invalid 'personal' boolean type, or non-whitelisted fields passed in the payload.","commonSituations":"API clients sending an empty or whitespace name, names longer than the column size (255), sending 'personal' as a string instead of boolean, or including read-only fields in the request body.","solutions":["Inspect the errors object in the 400 response to see which folder field failed and why.","Provide a non-empty 'name' within the column length limit (max 255 chars).","Only send editable fields (name, personal) with correct types: personal as boolean.","Fetch the folder first and patch only the fields that must change."],"exampleFix":"// before\nPUT /folders/{id} {\"name\":\"\"}\n// after\nPUT /folders/{id} {\"name\":\"Quarterly Budget\"}","handlingStrategy":"validation","validationCode":"function validateFolderMeta(data) {\n  const errors = {};\n  if (typeof data.name !== 'string' || data.name.trim() === '') errors.name = 'required';\n  if (data.name && data.name.length > 255) errors.name = 'max_length';\n  if ('personal' in data && typeof data.personal !== 'boolean') errors.personal = 'boolean';\n  return errors;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await foldersApi.update(folderId, meta);\n} catch (e) {\n  if (e.response?.status === 400 && e.response.data?.errors) {\n    // map entity errors back to form fields\n  }\n  throw e;\n}","preventionTips":["Enforce non-empty names and the 255-char limit in the client before submitting.","Send only whitelisted fields (name, personal) with correct JSON types.","Trim names to avoid whitespace-only values.","Surface the errors payload from 400 responses directly to the user."],"tags":["validation","folders","update","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"}