{"record":{"id":"d33d483b336fcb2b","repo":"passbolt/passbolt_api","slug":"could-not-update-the-authentication-token-data","errorCode":null,"errorMessage":"Could not update the authentication token data.","messagePattern":"Could not update the authentication token data\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"src/Service/Setup/RecoverCompleteService.php","lineNumber":54,"sourceCode":"     * @throws \\Cake\\Http\\Exception\\BadRequestException if no authentication token was provided\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the authentication token is not a uuid\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the authentication token is expired or invalid\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the OpenPGP key is not provided or not a valid OpenPGP key\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the OpenPGP key does not belong to the user\n     * @throws \\App\\Error\\Exception\\CustomValidationException if the token was already consumed by a concurrent request\n     * @param string $userId uuid of the user\n     * @return void\n     */\n    public function complete(string $userId): void\n    {\n        $this->AuthenticationTokens->getConnection()->transactional(function () use ($userId): void {\n            $user = $this->validateData($userId);\n            $token = $this->buildAuthenticationTokenEntity($userId);\n\n            $this->consumeTokenOrFail($token);\n\n            if (!$this->AuthenticationTokens->save($token)) {\n                throw new ValidationException(\n                    __('Could not update the authentication token data.'),\n                    $token,\n                    $this->AuthenticationTokens\n                );\n            }\n\n            $this->dispatchEvent(RecoverCompleteServiceInterface::COMPLETE_SUCCESS_EVENT_NAME, [\n                'user' => $user,\n                'data' => $this->request->getData(),\n                'clientIp' => $this->request->clientIp(),\n                'userAgent' => $this->request->getEnv('HTTP_USER_AGENT'),\n            ]);\n        });\n    }\n\n    /**\n     * Extension seam: subclasses may attach associations that `complete()` will cascade-save.\n     *","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Setup/RecoverCompleteService.php#L36-L72","documentation":"Thrown by RecoverCompleteService::complete when saving the freshly built authentication token entity back to the authentication_tokens table fails entity validation. The token was already consumed in memory, so a failed save leaves the recovery in an inconsistent state and surfaces as a ValidationException.","triggerScenarios":"Database-level validation failure on the token entity during update — e.g. schema constraint mismatch, unexpected field state, or a database connectivity/lock issue surfacing as a save error.","commonSituations":"Database schema drift after an incomplete migration; MariaDB/Postgres-specific column incompatibility; concurrent writes locking the row; corrupted token row in authentication_tokens.","solutions":["Run pending migrations (ddev refresh / cake migrations migrate) so authentication_tokens matches the expected schema","Retry the recover-complete request once the database is healthy; if it persists, inspect the entity errors via the ValidationException detail","Check the authentication_tokens row for the token id and fix or remove the corrupted row","Verify database connectivity and that no migration lock is held"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure migrations are current before the flow\nawait ensureMigrationsUpToDate(); // cake migrations status / migrate","typeGuard":null,"tryCatchPattern":"try { await recoverComplete(userId, token, key); }\ncatch (e) { if (isTokenSaveValidation(e)) { await retryWithBackoff(() => recoverComplete(...), 1); } else throw e; }","preventionTips":["Keep database migrations applied (ddev refresh)","Monitor DB health/locks during recovery flows","Inspect ValidationException entity errors when it recurs","Restore consistent state in authentication_tokens after corruption"],"tags":["recover","database-write","token"],"backgroundTag":"database-write-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}