{"record":{"id":"98f724dd0df96e1a","repo":"langgenius/dify","slug":"invalid-email-98f724","errorCode":"invalid_email","errorMessage":"The email address is not valid.","messagePattern":"The email address is not valid\\.","errorType":"error_code","errorClass":"InvalidEmailError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/auth/login.py","lineNumber":155,"sourceCode":"        invitation_data: InvitationDetailDict | None = None\n        if invite_token:\n            invitation_data = RegisterService.get_invitation_with_case_fallback(\n                None, request_email, invite_token, session=db.session()\n            )\n            if invitation_data is None:\n                invite_token = None\n\n        try:\n            if invitation_data:\n                data = invitation_data.get(\"data\", {})\n                invitee_email = data.get(\"email\") if data else None\n                invitee_email_normalized = invitee_email.lower() if isinstance(invitee_email, str) else invitee_email\n                if invitee_email_normalized != normalized_email:\n                    _log_console_login_failure(\n                        email=normalized_email,\n                        reason=LoginFailureReason.INVALID_INVITATION_EMAIL,\n                    )\n                    raise InvalidEmailError()\n            account = _authenticate_account_with_case_fallback(\n                request_email, normalized_email, req_data.password, invite_token\n            )\n        except services.errors.account.AccountLoginError:\n            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.ACCOUNT_BANNED)\n            raise AccountBannedError()\n        except services.errors.account.AccountPasswordError as exc:\n            AccountService.add_login_error_rate_limit(normalized_email)\n            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.INVALID_CREDENTIALS)\n            raise AuthenticationFailedError() from exc\n        tenants = TenantService.get_join_tenants(account, session=db.session())\n        if len(tenants) == 0:\n            if (\n                FeatureService.is_workspace_creation_allowed()\n                and not FeatureService.get_license().workspaces.is_available()\n            ):\n                raise WorkspacesLimitExceeded()\n            else:","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/auth/login.py#L137-L173","documentation":"Raised inside POST /console/api/login (HTTP 400, code invalid_email) when an invite_token resolves to an invitation whose data.email does not match the normalized login email. The controller fetches invitation_data via RegisterService.get_invitation_with_case_fallback, then compares invitee_email.lower() to normalized_email; mismatch raises InvalidEmailError.","triggerScenarios":"POST /console/api/login with an invite_token where the invited email differs (even by case, after normalization) from the email in the request body. Also raised if the invite was reissued to a different address.","commonSituations":"User signed in with a different email than the one they were invited with; invitation was forwarded to another account; user mistyped their email; stale invite_token copied from an old invitation link; SSO/email-alias mismatch where the user's primary email differs from the invited alias.","solutions":["Log in with the exact email address that appears on the invitation.","Request a new invitation sent to the email you actually want to use.","If you are the admin, revoke the old invitation and re-invite the correct email.","Remove the invite_token from the request body to do a plain password login without invitation binding."],"exampleFix":"// before\nfetch('/console/api/login', {body: JSON.stringify({email, password, invite_token})})\n// after - validate locally before sending\nif (invite_token && inviteEmail && inviteEmail.toLowerCase() !== email.toLowerCase()) {\n  setError('Please sign in with the email ' + inviteEmail)\n  return\n}\nfetch('/console/api/login', {body: JSON.stringify({email, password, invite_token})})","handlingStrategy":"validation","validationCode":"# Validate invitation email vs login email before submitting\ninvite = get_invitation_data(invite_token)\ninvited_email = invite['data']['email']\nif invited_email.lower() != login_email.lower():\n    warn_user(f'Please sign in with {invited_email}')\n    return\nsubmit_login(login_email, password, invite_token)","typeGuard":"null","tryCatchPattern":"from controllers.console.auth.error import InvalidEmailError\ntry:\n    do_login()\nexcept InvalidEmailError:\n    if invite_token:\n        prompt('Sign in with the email that received the invitation.')\n    else:\n        prompt('Check the email address.')","preventionTips":["Pre-fill the email field from the invitation data so users cannot diverge.","Drop the invite_token if the user explicitly chooses to log in without it.","Revoke invitations when reissuing to a different address."],"tags":["auth","login","invitation","email","validation"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}