langgenius/dify · error · InvalidEmailError

invalid_email

invalid_email

Error message

The email address is not valid.

What it means

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.

Source

Thrown at api/controllers/console/auth/login.py:155

        invitation_data: InvitationDetailDict | None = None
        if invite_token:
            invitation_data = RegisterService.get_invitation_with_case_fallback(
                None, request_email, invite_token, session=db.session()
            )
            if invitation_data is None:
                invite_token = None

        try:
            if invitation_data:
                data = invitation_data.get("data", {})
                invitee_email = data.get("email") if data else None
                invitee_email_normalized = invitee_email.lower() if isinstance(invitee_email, str) else invitee_email
                if invitee_email_normalized != normalized_email:
                    _log_console_login_failure(
                        email=normalized_email,
                        reason=LoginFailureReason.INVALID_INVITATION_EMAIL,
                    )
                    raise InvalidEmailError()
            account = _authenticate_account_with_case_fallback(
                request_email, normalized_email, req_data.password, invite_token
            )
        except services.errors.account.AccountLoginError:
            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.ACCOUNT_BANNED)
            raise AccountBannedError()
        except services.errors.account.AccountPasswordError as exc:
            AccountService.add_login_error_rate_limit(normalized_email)
            _log_console_login_failure(email=normalized_email, reason=LoginFailureReason.INVALID_CREDENTIALS)
            raise AuthenticationFailedError() from exc
        tenants = TenantService.get_join_tenants(account, session=db.session())
        if len(tenants) == 0:
            if (
                FeatureService.is_workspace_creation_allowed()
                and not FeatureService.get_license().workspaces.is_available()
            ):
                raise WorkspacesLimitExceeded()
            else:

View on GitHub (pinned to ef8544b173)

Solutions

  1. Log in with the exact email address that appears on the invitation.
  2. Request a new invitation sent to the email you actually want to use.
  3. If you are the admin, revoke the old invitation and re-invite the correct email.
  4. Remove the invite_token from the request body to do a plain password login without invitation binding.

Example fix

// before
fetch('/console/api/login', {body: JSON.stringify({email, password, invite_token})})
// after - validate locally before sending
if (invite_token && inviteEmail && inviteEmail.toLowerCase() !== email.toLowerCase()) {
  setError('Please sign in with the email ' + inviteEmail)
  return
}
fetch('/console/api/login', {body: JSON.stringify({email, password, invite_token})})
Defensive patterns

Strategy: validation

Validate before calling

# Validate invitation email vs login email before submitting
invite = get_invitation_data(invite_token)
invited_email = invite['data']['email']
if invited_email.lower() != login_email.lower():
    warn_user(f'Please sign in with {invited_email}')
    return
submit_login(login_email, password, invite_token)

Type guard

null

Try / catch

from controllers.console.auth.error import InvalidEmailError
try:
    do_login()
except InvalidEmailError:
    if invite_token:
        prompt('Sign in with the email that received the invitation.')
    else:
        prompt('Check the email address.')

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/98f724dd0df96e1a. Report an issue: GitHub.