{"record":{"id":"783d114637d35b6a","repo":"passbolt/passbolt_api","slug":"could-not-validate-group-data-groupsupdatedryrunservice","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/GroupsUpdateDryRunService.php","lineNumber":138,"sourceCode":"            if (!empty($errors)) {\n                $group->setError('groups_users', [$rowIndexRef => $errors]);\n                $this->handleValidationErrors($group);\n            }\n        }\n    }\n\n    /**\n     * Handle group validation errors.\n     *\n     * @param \\App\\Model\\Entity\\Group $group The target group\n     * @return void\n     * @throws \\App\\Error\\Exception\\ValidationException If the provided data does not validate.\n     */\n    private function handleValidationErrors(Group $group): void\n    {\n        $errors = $group->getErrors();\n        if (!empty($errors)) {\n            throw new ValidationException(__('Could not validate group data.'), $group, $this->groupsTable);\n        }\n    }\n\n    /**\n     * Get the secrets that will require to be encrypted for the users added to the group.\n     *\n     * @param \\App\\Model\\Entity\\Group $group The group to update.\n     * @param array $changes The list of group users changes.\n     * @return array A list of secrets to request to the client\n     * [\n     *   [\n     *     'resource_id' => uuid,\n     *     'user_id' => uuid\n     *   ],\n     *   ...\n     * ]\n     */\n    private function getAddedGroupsUsersMissingSecrets(Group $group, array $changes = []): array","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Groups/GroupsUpdateDryRunService.php#L120-L156","documentation":"GroupsUpdateDryRunService::handleValidationErrors() throws App\\Error\\Exception\\ValidationException with this message when a Group entity accumulated errors during the dry-run save. The exception carries the entity and table so the API can report per-field errors.","triggerScenarios":"During a dry-run group update (e.g. adding/removing group users in simulation mode) when entity save fails validation — invalid group name, invalid user modifications, rules like unique name failing.","commonSituations":"Renaming a group to a name that already exists; submitting changesets referencing users already in the group or nonexistent; seeding API payloads from outdated group state.","solutions":["Inspect the errors object in the response for the exact failing fields","Fix the offending fields (e.g. choose a unique group name)","Re-fetch group state before resubmitting to avoid stale changesets"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-checks before dry-run update\nconst names = (await api.get('/groups')).map(g => g.name);\nif (names.includes(newName)) throw new Error('group name already taken');\nif (!newMembers.every(u => existingUserIds.has(u.id))) throw new Error('unknown user in changeset');","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/groups/${id}/dry-run`, changes);\n} catch (e) {\n  if (e.response?.body?.errors || e.response?.data?.errors) {\n    console.error('Dry-run validation errors:', e.response.body.errors);\n  }\n  throw e;\n}","preventionTips":["Always run the dry-run first and fix all reported errors before the real update","Re-fetch group state right before submitting changesets","Keep group names unique and validate member ids against the users API"],"tags":["validation","groups","dry-run"],"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"}