{"record":{"id":"abcb2d2468c12206","repo":"passbolt/passbolt_api","slug":"could-not-validate-group-user-data-groupsusersupdateservice","errorCode":null,"errorMessage":"Could not validate group user data.","messagePattern":"Could not validate group user data\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"src/Service/GroupsUsers/GroupsUsersUpdateService.php","lineNumber":134,"sourceCode":"    private function saveGroupUser(GroupsUser $groupUser): void\n    {\n        $this->groupsUsersTable->save($groupUser);\n        if ($groupUser->hasErrors()) {\n            $this->handleValidationErrors($groupUser);\n        }\n    }\n\n    /**\n     * Handle groups users validation errors.\n     *\n     * @param \\App\\Model\\Entity\\GroupsUser $groupUser The list of errors\n     * @throws \\App\\Error\\Exception\\ValidationException If the provided data does not validate.\n     * @return void\n     */\n    private function handleValidationErrors(GroupsUser $groupUser): void\n    {\n        $msg = __('Could not validate group user data.');\n        throw new ValidationException($msg, $groupUser, $this->groupsUsersTable);\n    }\n}\n","sourceCodeStart":116,"sourceCodeEnd":137,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/GroupsUsers/GroupsUsersUpdateService.php#L116-L137","documentation":"GroupsUsersUpdateService::handleValidationErrors throws this ValidationException when the patched GroupsUser entity fails table-level save validation. It wraps the entity and the table so the response includes per-field validation errors (e.g. is_admin, user_id, group_id).","triggerScenarios":"PUT /groups/users/{id} with invalid data: is_admin not boolean, unknown group_user id, patching non-existent field, or save() failing on entity rules via patchGroupUserEntity or saveGroupUser.","commonSituations":"Sending is_admin as string 'true'/1 where strict validation rejects it, referencing a deleted group user, malformed request bodies, API clients not matching schema.","solutions":["Inspect the validation errors attached to the response body and fix the offending fields.","Ensure is_admin is a boolean and the group user id exists (GET /groups/{id}).","Send only schema fields (user_id, is_admin) with correct types.","Re-fetch the entity before patching to avoid stale/deleted ids."],"exampleFix":"// before\nawait passbolt.updateGroupUser(id, { is_admin: 'true' });\n// after\nawait passbolt.updateGroupUser(id, { is_admin: true });","handlingStrategy":"try-catch","validationCode":"if (typeof payload.is_admin !== 'boolean') throw new TypeError('is_admin must be boolean');","typeGuard":null,"tryCatchPattern":"try { await updateGroupUser(id, payload); } catch (e) { console.error(e.body?.errors); /* per-field errors */ }","preventionTips":["Validate payloads against the GroupsUser schema","Use boolean types for is_admin","Re-fetch entities before patching"],"tags":["groups","validation","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"}