{"record":{"id":"ca2a0f41bdb6ba97","repo":"passbolt/passbolt_api","slug":"could-not-validate-group-data-groupsupdateservice","errorCode":null,"errorMessage":"Could not validate group data.","messagePattern":"Could not validate group data\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"src/Service/Groups/GroupsUpdateService.php","lineNumber":204,"sourceCode":"        $metaData['modified_by'] = $uac->getId();\n        $this->groupsTable->patchEntity($group, $metaData, $groupPatchOptions);\n        $this->groupsTable->save($group);\n        if ($group->hasErrors()) {\n            $this->handleValidationErrors($group);\n        }\n    }\n\n    /**\n     * Handle group validation errors.\n     *\n     * @param \\App\\Model\\Entity\\Group $group The target group\n     * @throws \\App\\Error\\Exception\\ValidationException If the group has errors.\n     * @return void\n     */\n    private function handleValidationErrors(Group $group): void\n    {\n        $msg = __('Could not validate group data.');\n        throw new ValidationException($msg, $group, $this->groupsTable);\n    }\n\n    /**\n     * Add groups users.\n     *\n     * @note if the operator is not a group manager, requested additions will be ignored.\n     * @param \\App\\Utility\\UserAccessControl $uac The user at the origin of the operation\n     * @param \\App\\Model\\Entity\\Group $group The group to update.\n     * @param array $changes The list of group users changes.\n     * @param array $secretsData The list of secrets to add.\n     * @return \\App\\Model\\Dto\\EntitiesChangesDto Entities changes applied following the addition of users to groups\n     * @throws \\Exception If an unexpected error occurred.\n     */\n    private function addGroupsUsers(\n        UserAccessControl $uac,\n        Group $group,\n        array $changes,\n        array $secretsData","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Groups/GroupsUpdateService.php#L186-L222","documentation":"GroupsUpdateService::handleValidationErrors() throws App\\Error\\Exception\\ValidationException with this message whenever a Group entity fails validation during any part of a group update (metadata change, adding/updating/removing group users). The exception embeds the entity and table for detailed field errors.","triggerScenarios":"PUT /groups/{id} where any sub-operation triggers entity errors: invalid name, adding a user already in the group or nonexistent, deleting a nonexistent group user, metadata updates violating rules.","commonSituations":"Bulk updates where one invalid sub-change poisons the entity; concurrent edits where group state changed; permission-driven updates that are silently ignored leading to invalid final state.","solutions":["Read the per-field errors in the API response and correct those fields","Split large changesets into smaller PUT calls to isolate the failing change","Re-fetch the group before updating to ensure a fresh state","Validate that added users exist and are not already members"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const existing = await api.get(`/groups/${groupId}/users`);\nif (existing.some(u => u.user.id === userIdToAdd)) throw new Error('user already in group');\nif (!newName || newName.length < 1) throw new Error('group name required');","typeGuard":null,"tryCatchPattern":"try {\n  await api.put(`/groups/${groupId}`, changes);\n} catch (e) {\n  if (e.response?.body?.errors) {\n    const fieldErrors = e.response.body.errors;\n    // surface field-level errors to the user\n  }\n  throw e;\n}","preventionTips":["Split large group updates into small, independently retryable calls","Validate user existence and membership before adding","Handle concurrent edits by re-fetching the group before update","Always inspect errors in the ValidationException response body"],"tags":["validation","groups","rest-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"}