passbolt/passbolt_api · error · ValidationException

Could not validate the transfer data.

Error message

Could not validate the transfer data.

What it means

A ValidationException raised by TransfersCreateService::create when the freshly built Transfer entity fails CakePHP entity validation (field validators, not application rules). The exception carries the entity and table so the caller/serializer can surface per-field error details.

Solutions

  1. Inspect the ValidationException's error details (getErrors() on the entity) to see exactly which fields failed
  2. Send all required transfer fields: status, total_pages, current_page, and valid authentication_token data
  3. Ensure status uses the allowed constants (start, in_progress, complete, cancel)
  4. Verify the authentication token in the payload is a valid UUID owned by the authenticated user
  5. Align the client payload with the current Transfer validation rules after any server upgrade

Example fix

// before
$this->post('/mobile/transfers', ['total_pages' => 3]); // missing status, token
// after
$this->post('/mobile/transfers', [
  'status' => 'start',
  'total_pages' => 3,
  'current_page' => 0,
  'authentication_token' => ['token' => $validUuidToken],
]);
Defensive patterns

Strategy: validation

Validate before calling

const required = ['status','total_pages','current_page'];
required.forEach(f => { if (payload[f] === undefined) throw new Error(`missing field: ${f}`); });
if (!['start','in_progress','complete','cancel'].includes(payload.status)) throw new Error('invalid status');

Try / catch

try { return await createTransfer(payload); } catch (e) { if (e.status === 400 && e.body?.errors) { console.error('field errors:', e.body.errors); } throw e; }

Prevention

When it happens

Trigger: POST /mobile/transfers with data missing or violating Transfer validation rules — e.g. invalid/missing user_id, bad status value, non-numeric total_pages/current_page, missing authentication_token association data, or invalid auth token fields.

Common situations: Client sending snake_case vs camelCase field mismatches; omitting required fields like total_pages or status; passing a status string not in the allowed set; sending an authentication token that is not a valid UUID; API shape drift after a server upgrade.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at plugins/PassboltCe/Mobile/src/Service/Transfers/TransfersCreateService.php:67

        $this->Transfers = $transfersTable ?? TableRegistry::getTableLocator()->get('Passbolt/Mobile.Transfers');
    }

    /**
     * Create a transfer and the the associated authentication token
     *
     * @param array $data entity data
     * @param \App\Utility\UserAccessControl $uac user access control
     * @throws \App\Error\Exception\ValidationException if data do not validate
     * @throws \Cake\Http\Exception\InternalErrorException if saving data is not possible
     * @return \Passbolt\Mobile\Model\Entity\Transfer
     */
    public function create(array $data, UserAccessControl $uac): Transfer
    {
        // Check for validation errors
        $transfer = $this->buildTransferEntity($data, $uac);
        if ($transfer->getErrors()) {
            $msg = __('Could not validate the transfer data.');
            throw new ValidationException($msg, $transfer, $this->Transfers);
        }

        // Save and check for build rules errors.
        $transferSaved = $this->Transfers->save($transfer);
        if ($transfer->getErrors()) {
            $msg = __('Could not validate the transfer data.');
            throw new ValidationException($msg, $transfer, $this->Transfers);
        }

        // Check for errors while saving.
        if (!$transferSaved) {
            throw new InternalErrorException(__('The transfer could not be created.'));
        }

        return $transfer;
    }

    /**

View on GitHub (pinned to 31c1bbc10f)