{"record":{"id":"cfb4e737cf6e2715","repo":"langgenius/dify","slug":"account-not-found-cfb4e7","errorCode":"account_not_found","errorMessage":"Account not found.","messagePattern":"Account not found\\.","errorType":"error_code","errorClass":"AccountNotFound","httpStatus":400,"severity":"error","filePath":"api/controllers/console/auth/login.py","lineNumber":270,"sourceCode":"\n        ip_address = extract_remote_ip(request)\n        if AccountService.is_email_send_ip_limit(ip_address):\n            raise EmailSendIpLimitError()\n\n        if req_data.language is not None and req_data.language == \"zh-Hans\":\n            language = \"zh-Hans\"\n        else:\n            language = \"en-US\"\n        try:\n            account = _get_account_with_case_fallback(req_data.email)\n        except AccountRegisterError:\n            raise AccountInFreezeError()\n\n        if account is None:\n            if FeatureService.get_system_features().is_allow_register:\n                token = AccountService.send_email_code_login_email(email=normalized_email, language=language)\n            else:\n                raise AccountNotFound()\n        else:\n            token = AccountService.send_email_code_login_email(account=account, language=language)\n\n        return SimpleResultDataResponse(result=\"success\", data=token).model_dump(mode=\"json\")\n\n\n@console_ns.route(\"/email-code-login/validity\")\nclass EmailCodeLoginApi(Resource):\n    @setup_required\n    @console_ns.expect(console_ns.models[EmailCodeLoginPayload.__name__])\n    @console_ns.response(200, \"Success\", console_ns.models[SimpleResultResponse.__name__])\n    @decrypt_code_field\n    @model_validate(EmailCodeLoginPayload)\n    def post(self, req_data: EmailCodeLoginPayload):\n\n        original_email = req_data.email\n        user_email = original_email.lower()\n        language = req_data.language","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/auth/login.py#L252-L288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Have an admin invite the user, or enable registration via the system feature flag.","Verify the email address spelling and case.","Confirm the user is hitting the correct instance (URL/environment).","If registration should be allowed, check the config that backs FeatureService.get_system_features().is_allow_register."],"exampleFix":"# before\nif account is None:\n    if FeatureService.get_system_features().is_allow_register:\n        token = AccountService.send_email_code_login_email(email=normalized_email, language=language)\n    else:\n        raise AccountNotFound()\n# after - keep the security property but make the message actionable for known admins\nif account is None:\n    if FeatureService.get_system_features().is_allow_register:\n        token = AccountService.send_email_code_login_email(email=normalized_email, language=language)\n    else:\n        raise AccountNotFound(description='No account found and registration is disabled. Ask your admin to invite you.')","handlingStrategy":"validation","validationCode":"# If registration is disabled, check account existence first via an admin API\n# (public endpoints intentionally do not leak this). For admin context:\nexists = account_exists_in_workspace(email)\nif not exists and not FeatureService.get_system_features().is_allow_register:\n    prompt('No account found. Ask your admin to invite you.')\n    return\nrequest_code(email)","typeGuard":"null","tryCatchPattern":"from controllers.console.error import AccountNotFound\ntry:\n    request_code(email)\nexcept AccountNotFound:\n    prompt('No account found and registration is disabled. Ask your admin to invite you.')","preventionTips":["Keep is_allow_register and workspace-creation flags aligned with your onboarding policy.","Provide a clear invite request channel when registration is off.","Document the registration toggle in user-facing onboarding."],"tags":["auth","email-code-login","account","registration","configuration"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}