passbolt/passbolt_api · warning · BadRequestException

The request data is empty.

Error message

The request data is empty.

What it means

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.

Solutions

  1. Send a non-empty array of rbac update entries in the request body.
  2. Set Content-Type: application/json and send valid JSON.
  3. Have the client skip the call when there is nothing to update instead of sending an empty list.
  4. Validate the payload client-side before dispatching the request.

Example fix

// before
await api.put('/rbacs/update', []);
// after
if (updates.length > 0) {
  await api.put('/rbacs/update', updates);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!is_array($data) || count($data) === 0) {
    throw new InvalidArgumentException('rbacs update payload must be a non-empty array');
}

Try / catch

try {
    $collection = new RbacsUpdateDtoCollection($data);
} catch (BadRequestException $e) {
    // reject empty payload before calling the API
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/09dccc2f63f090e4. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltCe/Rbacs/src/Model/Dto/RbacsUpdateDtoCollection.php:102

    /**
     * @return int
     */
    public function count(): int
    {
        return count($this->data);
    }

    /**
     * Assert the whole data set is correct
     *
     * @throw BadRequestException if data is invalid
     * @param array $data data [{id:<uuid>, control_function:<string>},...]
     * @return void
     */
    public function assertdata(array $data): void
    {
        if (!count($data)) {
            throw new BadRequestException(__('The request data is empty.'));
        }
        foreach ($data as $entry) {
            if (!is_array($entry)) {
                throw new BadRequestException(__('The request data is invalid: expected a collection.'));
            }
            $this->assertEntry($entry);
        }

        $this->assertUniqueIds($data);
    }

    /**
     * Assert a given data entry
     *
     * @throw BadRequestException if entry doesn't match the expected format
     * @param array $entry entry {id:<uuid>, control_function:<string>}
     * @return void
     */

View on GitHub (pinned to 31c1bbc10f)