{"record":{"id":"dd5fee149ec29e41","repo":"passbolt/passbolt_api","slug":"the-authentication-token-could-not-be-found","errorCode":null,"errorMessage":"The authentication token could not be found.","messagePattern":"The authentication token could not be found\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Service/AuthenticationTokens/AuthenticationTokenGetService.php","lineNumber":105,"sourceCode":"     *\n     * @param string $token authentication token\n     * @param string $userId user ID\n     * @param string $type token type\n     * @return \\App\\Model\\Entity\\AuthenticationToken\n     * @throws \\Cake\\Http\\Exception\\NotFoundException if token is not found\n     * @throws \\App\\Error\\Exception\\CustomValidationException if the token is inactive\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if token id is not a valid uuid\n     */\n    public function getActiveOrFail(string $token, string $userId, string $type): AuthenticationToken\n    {\n        if (!Validation::uuid($token)) {\n            throw new BadRequestException(__('The token should be a valid UUID.'));\n        }\n\n        $tokenEntity = $this->get($token, $userId, $type);\n\n        if (!$tokenEntity) {\n            throw new NotFoundException(__('The authentication token could not be found.'));\n        }\n\n        if ($tokenEntity->isNotActive()) {\n            $error = [\n                'token' => [\n                    'isActive' => __('The token is already consumed.'),\n                ],\n            ];\n            throw new CustomValidationException(__('The authentication token is not valid.'), $error);\n        }\n\n        return $tokenEntity;\n    }\n\n    /**\n     * Get an authentication token given it's token, user identifier and type\n     *\n     * @param string $token authentication token","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/AuthenticationTokens/AuthenticationTokenGetService.php#L87-L123","documentation":"Existence check in AuthenticationTokenGetService::getActiveOrFail() (also reached via getNotCompletedOrFail and getActiveNotExpiredOrFail): the token is first validated as a UUID, then looked up for the given user and token type. This error fires when no authentication token entity matches — the token is wrong, was deleted, or belongs to another user — aborting flows such as setup/registration/recovery with a not-found failure; the client must request a new token.","triggerScenarios":"Querying with a UUID that does not exist for the given user_id and type (wrong type constant, wrong user, token deleted).","commonSituations":"Opening a link for a different user than the token was issued to; token already consumed then purged; copy/pasting token of another flow (register vs recover); test data wiped.","solutions":["Confirm the token, userId, and type passed match the record in authentication_tokens.","Resend the relevant email to generate a fresh token.","Check you are passing the correct AuthenticationToken type constant.","Verify the DB (or replica) actually contains the token row."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $token = $service->getActiveOrFail($token, $userId, $type);\n} catch (\\Cake\\Http\\Exception\\NotFoundException $e) {\n    // token/user/type combination not found — prompt resend\n}","preventionTips":["Always pass the same type constant that issued the token","Resend emails instead of reusing old links","Verify userId matches the token owner before lookup"],"tags":["php","auth-tokens","not-found"],"backgroundTag":"record-not-found","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"}