{"record":{"id":"6202c47c95c760ca","repo":"passbolt/passbolt_api","slug":"could-not-validate-the-transfer-data","errorCode":null,"errorMessage":"Could not validate the transfer data.","messagePattern":"Could not validate the transfer data\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Mobile/src/Service/Transfers/TransfersCreateService.php","lineNumber":67,"sourceCode":"        $this->Transfers = $transfersTable ?? TableRegistry::getTableLocator()->get('Passbolt/Mobile.Transfers');\n    }\n\n    /**\n     * Create a transfer and the the associated authentication token\n     *\n     * @param array $data entity data\n     * @param \\App\\Utility\\UserAccessControl $uac user access control\n     * @throws \\App\\Error\\Exception\\ValidationException if data do not validate\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if saving data is not possible\n     * @return \\Passbolt\\Mobile\\Model\\Entity\\Transfer\n     */\n    public function create(array $data, UserAccessControl $uac): Transfer\n    {\n        // Check for validation errors\n        $transfer = $this->buildTransferEntity($data, $uac);\n        if ($transfer->getErrors()) {\n            $msg = __('Could not validate the transfer data.');\n            throw new ValidationException($msg, $transfer, $this->Transfers);\n        }\n\n        // Save and check for build rules errors.\n        $transferSaved = $this->Transfers->save($transfer);\n        if ($transfer->getErrors()) {\n            $msg = __('Could not validate the transfer data.');\n            throw new ValidationException($msg, $transfer, $this->Transfers);\n        }\n\n        // Check for errors while saving.\n        if (!$transferSaved) {\n            throw new InternalErrorException(__('The transfer could not be created.'));\n        }\n\n        return $transfer;\n    }\n\n    /**","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Mobile/src/Service/Transfers/TransfersCreateService.php#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the ValidationException's error details (getErrors() on the entity) to see exactly which fields failed","Send all required transfer fields: status, total_pages, current_page, and valid authentication_token data","Ensure status uses the allowed constants (start, in_progress, complete, cancel)","Verify the authentication token in the payload is a valid UUID owned by the authenticated user","Align the client payload with the current Transfer validation rules after any server upgrade"],"exampleFix":"// before\n$this->post('/mobile/transfers', ['total_pages' => 3]); // missing status, token\n// after\n$this->post('/mobile/transfers', [\n  'status' => 'start',\n  'total_pages' => 3,\n  'current_page' => 0,\n  'authentication_token' => ['token' => $validUuidToken],\n]);","handlingStrategy":"validation","validationCode":"const required = ['status','total_pages','current_page'];\nrequired.forEach(f => { if (payload[f] === undefined) throw new Error(`missing field: ${f}`); });\nif (!['start','in_progress','complete','cancel'].includes(payload.status)) throw new Error('invalid status');","typeGuard":null,"tryCatchPattern":"try { return await createTransfer(payload); } catch (e) { if (e.status === 400 && e.body?.errors) { console.error('field errors:', e.body.errors); } throw e; }","preventionTips":["Mirror the server's Transfer validation rules in the client payload builder","Always read the per-field error details from the ValidationException body","Keep payloads in sync after server upgrades (check release notes)","Send 0-based integer page numbers and exact status enum strings"],"tags":["validation","mobile","transfers","cakephp","entity-validation"],"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"}