mirror of
https://github.com/langgenius/dify.git
synced 2026-12-03 19:18:14 +08:00
Resolve conflicts while retaining explicit application boundaries and current main behavior. Preserve credential refresh retries, optional indexing setup, QA answer updates, billing error handling, and generated API exports.
361 lines
12 KiB
Python
361 lines
12 KiB
Python
"""Framework-neutral errors shared by account application services."""
|
|
|
|
|
|
class AccountApplicationError(Exception):
|
|
"""Base class for failures owned by account application services."""
|
|
|
|
|
|
class AccountRegisterError(AccountApplicationError):
|
|
"""Account registration was rejected by a lifecycle policy."""
|
|
|
|
def __init__(self, description: str = "") -> None:
|
|
super().__init__(description)
|
|
self.description = description
|
|
|
|
|
|
class AccountLoginError(AccountApplicationError):
|
|
"""The account cannot sign in."""
|
|
|
|
|
|
class AccountPasswordError(AccountApplicationError):
|
|
"""The supplied sign-in password is incorrect."""
|
|
|
|
|
|
class SeatsLimitExceededError(AccountApplicationError):
|
|
"""The deployment has no capacity for another account."""
|
|
|
|
|
|
class AccountNotFoundError(AccountApplicationError):
|
|
"""The requested account does not exist."""
|
|
|
|
|
|
class AccountSessionNotFoundError(AccountApplicationError):
|
|
"""The requested access session is not owned by the admitted account."""
|
|
|
|
|
|
class InvalidInvitationError(AccountApplicationError):
|
|
"""The invitation is invalid, stale, or missing required activation data."""
|
|
|
|
|
|
class InvitationAccountMismatchError(AccountApplicationError):
|
|
"""An authenticated account attempted to consume another account's invitation."""
|
|
|
|
|
|
class FrozenAccountError(AccountApplicationError):
|
|
"""The invited account is temporarily ineligible for activation."""
|
|
|
|
|
|
class CurrentAccountPasswordIncorrectError(AccountApplicationError):
|
|
"""The supplied current password does not match the account credential."""
|
|
|
|
|
|
class InvalidAccountPasswordError(AccountApplicationError):
|
|
"""The requested password does not satisfy the account password policy."""
|
|
|
|
|
|
class ForgotPasswordSendIPLimitedError(AccountApplicationError):
|
|
"""The caller IP exceeded the email-send policy."""
|
|
|
|
|
|
class ForgotPasswordSendRateLimitError(AccountApplicationError):
|
|
"""Too many password-reset messages were requested for the address."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|
|
|
|
|
|
class ForgotPasswordVerificationLimitError(AccountApplicationError):
|
|
"""Too many invalid password-reset codes were submitted."""
|
|
|
|
|
|
class InvalidForgotPasswordTokenError(AccountApplicationError):
|
|
"""The password-reset token is absent, malformed, or in the wrong phase."""
|
|
|
|
|
|
class InvalidForgotPasswordEmailError(AccountApplicationError):
|
|
"""The request address does not match the password-reset token."""
|
|
|
|
|
|
class InvalidForgotPasswordCodeError(AccountApplicationError):
|
|
"""The verification code does not match the password-reset token."""
|
|
|
|
|
|
class ForgotPasswordMismatchError(AccountApplicationError):
|
|
"""The password and its confirmation do not match."""
|
|
|
|
|
|
class AvatarFileNotFoundError(AccountApplicationError):
|
|
"""The requested avatar file does not exist or is not owned by the account."""
|
|
|
|
|
|
class AccountAlreadyInitializedError(AccountApplicationError):
|
|
"""The account is already active and cannot be initialized again."""
|
|
|
|
|
|
class MissingInvitationCodeError(AccountApplicationError):
|
|
"""Cloud account initialization requires an invitation code."""
|
|
|
|
|
|
class InvalidInvitationCodeError(AccountApplicationError):
|
|
"""The invitation code is missing, used, or otherwise invalid."""
|
|
|
|
|
|
class InvalidAccountDeletionVerificationError(AccountApplicationError):
|
|
"""The account deletion token or verification code is invalid."""
|
|
|
|
|
|
class AccountDeletionRateLimitError(AccountApplicationError):
|
|
"""Too many account deletion verification emails were requested."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|
|
|
|
|
|
class ChangeEmailSendIPLimitedError(AccountApplicationError):
|
|
"""The caller IP exceeded the email-send policy."""
|
|
|
|
|
|
class ChangeEmailSendRateLimitError(AccountApplicationError):
|
|
"""Too many change-email messages were requested for the address."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|
|
|
|
|
|
class InvalidChangeEmailTokenError(AccountApplicationError):
|
|
"""The token is absent, malformed, in the wrong phase, or bound elsewhere."""
|
|
|
|
|
|
class InvalidChangeEmailAddressError(AccountApplicationError):
|
|
"""The request address does not match the account or token state."""
|
|
|
|
|
|
class ChangeEmailVerificationLimitError(AccountApplicationError):
|
|
"""Too many invalid verification-code attempts were made."""
|
|
|
|
|
|
class InvalidChangeEmailCodeError(AccountApplicationError):
|
|
"""The verification code does not match the current token."""
|
|
|
|
|
|
class AccountEmailFrozenError(AccountRegisterError):
|
|
"""The target email is temporarily frozen by account policy."""
|
|
|
|
|
|
class AccountEmailDomainSuspendedError(AccountEmailFrozenError):
|
|
"""The target email belongs to a suspended domain."""
|
|
|
|
def __init__(self, description: str = "This email domain has been suspended.") -> None:
|
|
super().__init__(description)
|
|
|
|
|
|
class AccountEmailAlreadyInUseError(AccountRegisterError):
|
|
"""The target email already belongs to an account."""
|
|
|
|
|
|
class AccountNormalizedEmailAlreadyInUseError(AccountEmailAlreadyInUseError):
|
|
"""A normalized equivalent of the target email already belongs to an account."""
|
|
|
|
|
|
class EmailRegistrationSendIPLimitedError(AccountApplicationError):
|
|
"""The caller IP exceeded the registration-email send policy."""
|
|
|
|
|
|
class EmailRegistrationSendRateLimitError(AccountApplicationError):
|
|
"""Too many registration messages were requested for the address."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|
|
|
|
|
|
class EmailRegistrationVerificationLimitError(AccountApplicationError):
|
|
"""Too many invalid registration-code attempts were made."""
|
|
|
|
|
|
class InvalidEmailRegistrationTokenError(AccountApplicationError):
|
|
"""The registration token is absent, malformed, or in the wrong phase."""
|
|
|
|
|
|
class InvalidEmailRegistrationAddressError(AccountApplicationError):
|
|
"""The request address does not match the registration token."""
|
|
|
|
|
|
class InvalidEmailRegistrationCodeError(AccountApplicationError):
|
|
"""The verification code does not match the registration token."""
|
|
|
|
|
|
class EmailRegistrationPasswordMismatchError(AccountApplicationError):
|
|
"""The registration password confirmation does not match."""
|
|
|
|
|
|
class EmailRegistrationSeatsLimitError(AccountApplicationError):
|
|
"""The deployment has no licensed seat available for another account."""
|
|
|
|
|
|
class EmailRegistrationWorkspaceLimitError(AccountApplicationError):
|
|
"""The deployment has no licensed workspace available for registration."""
|
|
|
|
|
|
class EducationDiscountPausedError(AccountApplicationError):
|
|
"""Education discount activation is temporarily paused."""
|
|
|
|
|
|
class InvalidOAuthProviderError(AccountApplicationError):
|
|
"""The requested Console OAuth provider is unavailable."""
|
|
|
|
|
|
class OAuthProviderRequestError(AccountApplicationError):
|
|
"""The remote OAuth provider could not complete the request."""
|
|
|
|
|
|
class OAuthProviderAuthorizationError(AccountApplicationError):
|
|
"""The remote OAuth provider rejected the authorization exchange."""
|
|
|
|
def __init__(self, description: str) -> None:
|
|
super().__init__(description)
|
|
self.description = description
|
|
|
|
|
|
class OAuthIdentityLockUnavailableError(AccountApplicationError):
|
|
"""The OAuth account claim could not be acquired or its lease was lost."""
|
|
|
|
|
|
class InvalidOAuthInvitationError(AccountApplicationError):
|
|
"""The OAuth callback references an invitation that can no longer be resolved."""
|
|
|
|
|
|
class OAuthInvitationAccountMismatchError(AccountApplicationError):
|
|
"""The OAuth identity does not own the account referenced by the invitation."""
|
|
|
|
def __init__(self, invite_token: str) -> None:
|
|
super().__init__(invite_token)
|
|
self.invite_token = invite_token
|
|
|
|
|
|
class OAuthAccountBannedError(AccountApplicationError):
|
|
"""The OAuth identity resolves to a banned Console account."""
|
|
|
|
|
|
class OAuthAccountNotFoundError(AccountApplicationError):
|
|
"""An account disappeared while the OAuth use case was running."""
|
|
|
|
|
|
class OAuthWorkspaceCreationNotAllowedError(AccountApplicationError):
|
|
"""Workspace policy prevents provisioning a workspace for the OAuth account."""
|
|
|
|
|
|
class OAuthSeatsLimitExceededError(AccountApplicationError):
|
|
"""Account registration would exceed the licensed seat limit."""
|
|
|
|
|
|
class OAuthRegistrationError(AccountApplicationError):
|
|
"""The OAuth account could not be registered."""
|
|
|
|
def __init__(self, description: str) -> None:
|
|
super().__init__(description)
|
|
self.description = description
|
|
|
|
|
|
class EducationRateLimitExceededError(AccountApplicationError):
|
|
"""Too many education verification or activation requests were made."""
|
|
|
|
|
|
class EducationVerificationFailedError(AccountApplicationError):
|
|
"""The billing service could not verify the account's education identity."""
|
|
|
|
|
|
class EducationActivationFailedError(AccountApplicationError):
|
|
"""The billing service could not create the account's education identity."""
|
|
|
|
|
|
class EducationRequestInProgressError(AccountApplicationError):
|
|
"""An earlier education request for the account is still being processed."""
|
|
|
|
|
|
class LoginRateLimitError(AccountApplicationError):
|
|
"""Too many failed password-login attempts were made for the address."""
|
|
|
|
|
|
class InvalidLoginCredentialsError(AccountApplicationError):
|
|
"""The supplied login credentials are invalid."""
|
|
|
|
|
|
class LoginAccountBannedError(AccountApplicationError):
|
|
"""The account is banned from signing in."""
|
|
|
|
|
|
class InvalidLoginInvitationEmailError(AccountApplicationError):
|
|
"""The invitation belongs to a different email address."""
|
|
|
|
|
|
class LoginWorkspaceLimitError(AccountApplicationError):
|
|
"""A required workspace cannot be created because the limit was reached."""
|
|
|
|
|
|
class LoginInvitationQuotaError(AccountApplicationError):
|
|
"""The invitation cannot be accepted because its account or workspace quota is exhausted."""
|
|
|
|
def __init__(self, *, seats: bool) -> None:
|
|
super().__init__()
|
|
self.seats = seats
|
|
|
|
|
|
class LoginWorkspaceCreationNotAllowedError(AccountApplicationError):
|
|
"""Workspace creation is disabled for this deployment."""
|
|
|
|
|
|
class LoginSeatLimitError(AccountApplicationError):
|
|
"""A new account cannot be created because the seat limit was reached."""
|
|
|
|
|
|
class EmailCodeSendIPLimitedError(AccountApplicationError):
|
|
"""The caller IP exceeded the email-code send policy."""
|
|
|
|
|
|
class EmailCodeSendRateLimitError(AccountApplicationError):
|
|
"""Too many email-code messages were requested for the address."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|
|
|
|
|
|
class HumanVerificationRejectedError(AccountApplicationError):
|
|
"""The anti-bot challenge was rejected."""
|
|
|
|
|
|
class HumanVerificationUnavailableError(AccountApplicationError):
|
|
"""The anti-bot verification provider is unavailable."""
|
|
|
|
|
|
class EmailCodeLoginUnavailableError(AccountApplicationError):
|
|
"""The email-code challenge store is unavailable."""
|
|
|
|
|
|
class InvalidEmailCodeTokenError(AccountApplicationError):
|
|
"""The email-code token is invalid or no longer usable."""
|
|
|
|
|
|
class EmailCodeEmailMismatchError(AccountApplicationError):
|
|
"""The email-code token belongs to a different address."""
|
|
|
|
|
|
class InvalidEmailCodeError(AccountApplicationError):
|
|
"""The supplied email verification code is invalid."""
|
|
|
|
|
|
class InvalidRefreshTokenError(AccountApplicationError):
|
|
"""The refresh token cannot be exchanged for a new session."""
|
|
|
|
|
|
class ResetPasswordEmailRateLimitError(AccountApplicationError):
|
|
"""Too many reset-password messages were requested for the address."""
|
|
|
|
def __init__(self, retry_after_minutes: int) -> None:
|
|
super().__init__(retry_after_minutes)
|
|
self.retry_after_minutes = retry_after_minutes
|