{"record":{"id":"09dccc2f63f090e4","repo":"passbolt/passbolt_api","slug":"the-request-data-is-empty","errorCode":null,"errorMessage":"The request data is empty.","messagePattern":"The request data is empty\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"plugins/PassboltCe/Rbacs/src/Model/Dto/RbacsUpdateDtoCollection.php","lineNumber":102,"sourceCode":"    /**\n     * @return int\n     */\n    public function count(): int\n    {\n        return count($this->data);\n    }\n\n    /**\n     * Assert the whole data set is correct\n     *\n     * @throw BadRequestException if data is invalid\n     * @param array $data data [{id:<uuid>, control_function:<string>},...]\n     * @return void\n     */\n    public function assertdata(array $data): void\n    {\n        if (!count($data)) {\n            throw new BadRequestException(__('The request data is empty.'));\n        }\n        foreach ($data as $entry) {\n            if (!is_array($entry)) {\n                throw new BadRequestException(__('The request data is invalid: expected a collection.'));\n            }\n            $this->assertEntry($entry);\n        }\n\n        $this->assertUniqueIds($data);\n    }\n\n    /**\n     * Assert a given data entry\n     *\n     * @throw BadRequestException if entry doesn't match the expected format\n     * @param array $entry entry {id:<uuid>, control_function:<string>}\n     * @return void\n     */","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Rbacs/src/Model/Dto/RbacsUpdateDtoCollection.php#L84-L120","documentation":"Validation guard in RbacsUpdateDtoCollection::assertdata() (reached via the constructor): the RBAC update payload must be a non-empty array of {id, control_function} entries. Fires when the client submits an empty request body/empty array for the RBAC settings update, in which case there is nothing to persist and the operation is rejected with HTTP 400 rather than silently succeeding.","triggerScenarios":"Calling new RbacsUpdateDtoCollection([]) (e.g. from the RbacsUpdateController) when the request body contains no items — empty JSON array, missing body, or wrong content type so the body parses to nothing.","commonSituations":"Client sending PUT /rbacs/update with an empty list, requests without a JSON body or with Content-Type not set to application/json so the body is not parsed.","solutions":["Send a non-empty array of rbac update entries in the request body.","Set Content-Type: application/json and send valid JSON.","Have the client skip the call when there is nothing to update instead of sending an empty list.","Validate the payload client-side before dispatching the request."],"exampleFix":"// before\nawait api.put('/rbacs/update', []);\n// after\nif (updates.length > 0) {\n  await api.put('/rbacs/update', updates);\n}","handlingStrategy":"validation","validationCode":"if (!is_array($data) || count($data) === 0) {\n    throw new InvalidArgumentException('rbacs update payload must be a non-empty array');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $collection = new RbacsUpdateDtoCollection($data);\n} catch (BadRequestException $e) {\n    // reject empty payload before calling the API\n}","preventionTips":["Skip API calls when there is nothing to update.","Ensure Content-Type: application/json and a parsed body.","Add a client-side check for empty arrays before sending.","Log request bodies to catch empty payloads early."],"tags":["php","cakephp","rbacs","bad-request","empty-payload"],"backgroundTag":"empty-required-field","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"}