{"record":{"id":"9dff15823e862ae9","repo":"makeplane/plane","slug":"5095","errorCode":"5095","errorMessage":"EXPIRED_MAGIC_CODE_SIGN_IN","messagePattern":"EXPIRED_MAGIC_CODE_SIGN_IN","errorType":"exception","errorClass":"AuthenticationException","httpStatus":null,"severity":"warning","filePath":"apps/api/plane/authentication/provider/credentials/magic_code.py","lineNumber":201,"sourceCode":"                        payload={\"email\": str(email)},\n                    )\n\n                if user_exists:\n                    raise AuthenticationException(\n                        error_code=AUTHENTICATION_ERROR_CODES[\"INVALID_MAGIC_CODE_SIGN_IN\"],\n                        error_message=\"INVALID_MAGIC_CODE_SIGN_IN\",\n                        payload={\"email\": str(email)},\n                    )\n                else:\n                    raise AuthenticationException(\n                        error_code=AUTHENTICATION_ERROR_CODES[\"INVALID_MAGIC_CODE_SIGN_UP\"],\n                        error_message=\"INVALID_MAGIC_CODE_SIGN_UP\",\n                        payload={\"email\": str(email)},\n                    )\n        else:\n            email = str(self.key).replace(\"magic_\", \"\", 1)\n            if User.objects.filter(email=email).exists():\n                raise AuthenticationException(\n                    error_code=AUTHENTICATION_ERROR_CODES[\"EXPIRED_MAGIC_CODE_SIGN_IN\"],\n                    error_message=\"EXPIRED_MAGIC_CODE_SIGN_IN\",\n                    payload={\"email\": str(email)},\n                )\n            else:\n                raise AuthenticationException(\n                    error_code=AUTHENTICATION_ERROR_CODES[\"EXPIRED_MAGIC_CODE_SIGN_UP\"],\n                    error_message=\"EXPIRED_MAGIC_CODE_SIGN_UP\",\n                    payload={\"email\": str(email)},\n                )\n","sourceCodeStart":183,"sourceCodeEnd":212,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/authentication/provider/credentials/magic_code.py#L183-L212","documentation":"Raised in MagicCodeProvider.set_user_data (magic_code.py:201) in the else-branch where the Redis key self.key does NOT exist (token missing or expired) AND a User exists for the cleaned email. Code 5095, payload {email}. This means no valid token to verify against — the code was never issued, already used, or expired.","triggerScenarios":"Calling verify when ri.exists(self.key) is False: the 600s TTL elapsed, the token was consumed by a successful login, invalidated by exhaustion, or Redis was flushed. If the email maps to an existing User, AuthenticationException code 5095 is raised.","commonSituations":"User waits too long (>600s) before entering the code; user already used the code and clicks verify again; Redis restart/flush dropped the key; user is verifying against a code from an old email after requesting a new one (which reused/overwrote the key).","solutions":["Request a fresh magic code and verify within the 600s TTL.","Ensure only the newest code is used (requesting a new code invalidates the prior token context for that key).","If persistent, check Redis connectivity and that the magic_* keys are not being evicted (maxmemory policy)."],"exampleFix":"// before: verify after 600s, key expired, user exists -> 5095\n// after: regenerate code, verify immediately","handlingStrategy":"validation","validationCode":"from plane.settings.redis import redis_instance\n\ndef token_still_valid(token_key: str) -> bool:\n    ri = redis_instance()\n    return bool(ri.exists(token_key)) and (ri.ttl(token_key) > 0)","typeGuard":null,"tryCatchPattern":"try:\n    provider.set_user_data()\nexcept AuthenticationException as e:\n    if e.error_code == 5095:\n        provider.initiate()  # issue a fresh code for the existing user\n    else:\n        raise","preventionTips":["Verify the code within the 600s TTL.","Requesting a new code supersedes the old one; use the newest."],"tags":["authentication","magic-code","expired","redis","signin"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}