{"record":{"id":"7578dfef1c9b6546","repo":"passbolt/passbolt_api","slug":"the-request-is-invalid","errorCode":null,"errorMessage":"The request is invalid.","messagePattern":"The request is invalid\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryRequestsTable.php","lineNumber":428,"sourceCode":"            'armored_key' => $data['armored_key'] ?? '',\n            'fingerprint' => $data['fingerprint'] ?? '',\n            'status' => AccountRecoveryRequest::ACCOUNT_RECOVERY_REQUEST_PENDING,\n            'created_by' => $uac->getId(),\n            'modified_by' => $uac->getId(),\n        ], [\n            'accessibleFields' => [\n                'authentication_token_id' => true,\n                'user_id' => true,\n                'armored_key' => true,\n                'fingerprint' => true,\n                'status' => true,\n                'created_by' => true,\n                'modified_by' => true,\n            ],\n        ]);\n\n        if ($requestEntity->getErrors()) {\n            throw new ValidationException(__('The request is invalid.'), $requestEntity, $this);\n        }\n\n        return $requestEntity;\n    }\n\n    /**\n     * Patch a request from a response\n     *\n     * @param \\App\\Utility\\UserAccessControl $uac user access control\n     * @param \\Passbolt\\AccountRecovery\\Model\\Entity\\AccountRecoveryRequest $requestEntity request\n     * @param string $responseStatus data\n     * @return \\Passbolt\\AccountRecovery\\Model\\Entity\\AccountRecoveryRequest\n     */\n    public function updateStatusAndValidateEntity(\n        UserAccessControl $uac,\n        AccountRecoveryRequest $requestEntity,\n        string $responseStatus\n    ): AccountRecoveryRequest {","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/AccountRecovery/src/Model/Table/AccountRecoveryRequestsTable.php#L410-L446","documentation":"A ValidationException thrown when the account recovery request entity built in buildAndValidateEntity fails the table's validation rules (e.g. invalid user_id, status value, or missing required fields). The entity with its errors is attached to the exception.","triggerScenarios":"Creating a recovery request with a non-existent/invalid user_id, an unsupported status string, or missing created_by/modified_by fields.","commonSituations":"Starting account recovery for a user id that fails entity-level validation; custom integrations posting request entities directly; status enum drift between client and server versions.","solutions":["Inspect the attached entity errors to identify the failing field.","Use the official POST /account-recovery/requests endpoint with only user_id in the payload.","Ensure the user exists and the id is a valid UUID.","Align client/server versions so status values match the supported enum."],"exampleFix":"// before\nTable.save({user_id: userId, status: 'pending', foo: 'bar'});\n// after\nTable.save({user_id: userId}); // status managed by the server","handlingStrategy":"try-catch","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!userId || !UUID_RE.test(userId)) throw new Error('user id must be a UUID');","typeGuard":"function isUuid(v) { return typeof v === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v); }","tryCatchPattern":"try { await api.startAccountRecovery({user_id: userId}); } catch (e) { if (e.body && e.body.account_recovery_request) { reportFieldErrors(e.body.account_recovery_request); } else { throw e; } }","preventionTips":["Send only the fields the endpoint documents (user_id).","Confirm the user exists before starting recovery.","Read attached entity errors for the failing field.","Avoid writing request entities directly from custom code."],"tags":["validation","entity","account-recovery","request"],"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"}