{"record":{"id":"4faf95e30365bb72","repo":"passbolt/passbolt_api","slug":"some-user-data-should-be-provided","errorCode":null,"errorMessage":"Some user data should be provided.","messagePattern":"Some user data should be provided\\.","errorType":"exception","errorClass":"Cake\\Http\\Exception\\BadRequestException","httpStatus":400,"severity":"warning","filePath":"src/Controller/Users/UsersEditController.php","lineNumber":170,"sourceCode":"        }\n        if ($this->User->role() !== Role::ADMIN && (isset($data['role']) || isset($data['role_id']))) {\n            throw new ForbiddenException(__('You are not authorized to edit the role.'));\n        }\n    }\n\n    /**\n     * Validate the data coming from the request\n     *\n     * @param array $data user data\n     * @return void\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if gpgkey is sent (v2 only)\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if groups data is sent (v2 only)\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if data is not provided or invalid\n     */\n    protected function assertRequestData(array $data): void\n    {\n        if (empty($data) || count($data) < 2) {\n            throw new BadRequestException(__('Some user data should be provided.'));\n        }\n        if (isset($data['gpgkey'])) {\n            throw new BadRequestException(__('Updating the OpenPGP key is not allowed.'));\n        }\n        if (isset($data['groups_user'])) {\n            throw new BadRequestException(__('Updating the groups is not allowed.'));\n        }\n    }\n\n    /**\n     * Sends an email to all admins when a user has been disabled\n     * Sends an email to the user disabled if that user is an admin\n     *\n     * @param \\App\\Model\\Entity\\User $user User being edited\n     * @return void\n     */\n    protected function sendEmailOnUserDisable(User $user): void\n    {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Users/UsersEditController.php#L152-L188","documentation":"BadRequestException (HTTP 400) from assertRequestData: the edit payload is empty or has fewer than two top-level entries, so there is nothing meaningful to update (at minimum `id` plus one field). The controller rejects no-op edits early.","triggerScenarios":"PUT /users/{id}.json with an empty body, or a body containing only `id` (count < 2).","commonSituations":"Client builds a diff object that ends up empty because nothing changed; serialization drops all fields; form submitted without any modifications; a bug stripping the payload before send.","solutions":["Send at least `id` plus one actual field to update, or skip the request when there is no change.","Check client diffing/serialization logic so changed fields are not dropped.","Validate the payload is non-empty before calling the API."],"exampleFix":"// before\nconst changes = diff(currentUser, newUser); // may be {}\nif (Object.keys(changes).length) await api.editUser(id, { id, ...changes });\n// after\nif (!Object.keys(changes).length) return; // skip update entirely\nawait api.editUser(id, { id, ...changes });","handlingStrategy":"validation","validationCode":"function isMeaningfulEdit(data) { return data && Object.keys(data).length >= 2; } // id + at least one field\nif (!isMeaningfulEdit(payload)) throw new Error('No user changes to save');","typeGuard":null,"tryCatchPattern":"try { await api.editUser(id, data); } catch (e) { if (e.code === 400 && /Some user data should be provided/.test(e.message)) { return; /* nothing to update */ } throw e; }","preventionTips":["Skip update calls when the computed diff is empty.","Log payload size before sending to catch serialization bugs early.","Unit-test diff/serialization logic so changed fields are never dropped."],"tags":["bad-request","empty-payload","http-400","users"],"backgroundTag":"missing-required-argument","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"}