langgenius/dify · error · AccountNotFound

account_not_found

account_not_found

Error message

Account not found.

What it means

Raised by POST /console/api/email-code-login (HTTP 400, code account_not_found) when _get_account_with_case_fallback returns None (no matching account) AND FeatureService.get_system_features().is_allow_register is false. With registration disabled, an unknown email cannot be issued a code-login email, so the controller raises AccountNotFound.

Source

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

        ip_address = extract_remote_ip(request)
        if AccountService.is_email_send_ip_limit(ip_address):
            raise EmailSendIpLimitError()

        if req_data.language is not None and req_data.language == "zh-Hans":
            language = "zh-Hans"
        else:
            language = "en-US"
        try:
            account = _get_account_with_case_fallback(req_data.email)
        except AccountRegisterError:
            raise AccountInFreezeError()

        if account is None:
            if FeatureService.get_system_features().is_allow_register:
                token = AccountService.send_email_code_login_email(email=normalized_email, language=language)
            else:
                raise AccountNotFound()
        else:
            token = AccountService.send_email_code_login_email(account=account, language=language)

        return SimpleResultDataResponse(result="success", data=token).model_dump(mode="json")


@console_ns.route("/email-code-login/validity")
class EmailCodeLoginApi(Resource):
    @setup_required
    @console_ns.expect(console_ns.models[EmailCodeLoginPayload.__name__])
    @console_ns.response(200, "Success", console_ns.models[SimpleResultResponse.__name__])
    @decrypt_code_field
    @model_validate(EmailCodeLoginPayload)
    def post(self, req_data: EmailCodeLoginPayload):

        original_email = req_data.email
        user_email = original_email.lower()
        language = req_data.language

View on GitHub (pinned to ef8544b173)

Solutions

  1. Have an admin invite the user, or enable registration via the system feature flag.
  2. Verify the email address spelling and case.
  3. Confirm the user is hitting the correct instance (URL/environment).
  4. If registration should be allowed, check the config that backs FeatureService.get_system_features().is_allow_register.

Example fix

# before
if account is None:
    if FeatureService.get_system_features().is_allow_register:
        token = AccountService.send_email_code_login_email(email=normalized_email, language=language)
    else:
        raise AccountNotFound()
# after - keep the security property but make the message actionable for known admins
if account is None:
    if FeatureService.get_system_features().is_allow_register:
        token = AccountService.send_email_code_login_email(email=normalized_email, language=language)
    else:
        raise AccountNotFound(description='No account found and registration is disabled. Ask your admin to invite you.')
Defensive patterns

Strategy: validation

Validate before calling

# If registration is disabled, check account existence first via an admin API
# (public endpoints intentionally do not leak this). For admin context:
exists = account_exists_in_workspace(email)
if not exists and not FeatureService.get_system_features().is_allow_register:
    prompt('No account found. Ask your admin to invite you.')
    return
request_code(email)

Type guard

null

Try / catch

from controllers.console.error import AccountNotFound
try:
    request_code(email)
except AccountNotFound:
    prompt('No account found and registration is disabled. Ask your admin to invite you.')

Prevention

When it happens

Trigger: POST /console/api/email-code-login from an IP that is not rate-limited, for an email with no account, on a deployment where registration is disabled (is_allow_register=false). The else branch of the registration-allowed check raises AccountNotFound.

Common situations: Self-hosted instance with sign-up turned off and the user has no account; typo in the email address; user belongs to a different deployment/environment; registration was disabled by an admin after the user last logged in.

Related errors


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