User Accounts Service Errors¶
consortium.server.exceptions.service_exceptions.user_accounts_service_exceptions
¶
Exception hierarchy:
BaseServiceError
UserAccountsServiceError(message='', detail=None)
¶
Bases: BaseServiceError
Base exception for all errors that occur within the user accounts service.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
A stable machine-readable string identifying the specific error. |
|
message |
str
|
A human-readable description of what went wrong and, where possible, how to resolve it. |
detail |
dict[str, JsonValue] | None
|
Optional structured context about the error, or None when there is none. |
code = 'USER_ACCOUNTS_SERVICE_ERROR'
class-attribute
instance-attribute
¶
UserAccountNotFoundError(message='', detail=None)
¶
Bases: UserAccountsServiceError
Base exception raised when the requested user account was not found in the user accounts service.
code = 'USER_ACCOUNT_NOT_FOUND_ERROR'
class-attribute
instance-attribute
¶
UserAccountIDNotFoundError(user_account_id)
¶
Bases: UserAccountNotFoundError
Raised when the requested user account was not found by user account ID in the user accounts service.
code = 'USER_ACCOUNT_ID_NOT_FOUND_ERROR'
class-attribute
instance-attribute
¶
UserAccountUsernameNotFoundError(username)
¶
Bases: UserAccountNotFoundError
Raised when the requested user account was not found by username in the user accounts service.
code = 'USER_ACCOUNT_USERNAME_NOT_FOUND_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileError(message='', detail=None)
¶
Bases: UserAccountsServiceError
Base exception for every failure to get the user accounts file's data on or off disk.
Catch this to handle "the user accounts did not make it in or out" without caring
why. To distinguish a filesystem fault from a bad file, catch
UserAccountsFileSystemError or UserAccountsFileContentError instead.
code = 'USER_ACCOUNTS_FILE_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileSystemError(operation, path, underlying_error)
¶
Bases: UserAccountsFileError
Raised when the user accounts file cannot be read from or written to disk.
This covers every way the filesystem can refuse the operation: the file does not
exist, the process lacks the required permissions, the configured path points at a
directory, the disk is full. They share one type because no caller can act differently
on any of them. All of them mean the operation did not happen, and the specific cause
is carried in message and detail for whoever has to fix it.
These are server side faults or misconfiguration: no user accounts operation takes a filesystem path from a client, so a failure here reflects the state of the machine the server is running on, the path it was configured with, or a bug in the code that supplied that path.
A file the filesystem hands over successfully but whose contents are wrong is reported
separately, through UserAccountsFileContentError.
code = 'USER_ACCOUNTS_FILE_SYSTEM_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileContentError(message='', detail=None)
¶
Bases: UserAccountsFileError
Base exception for all errors that occur when the user accounts file's contents are wrong.
The filesystem handed the file's bytes over successfully, so this is fixed by correcting the file rather than by changing the state of the machine or the configured path.
code = 'USER_ACCOUNTS_FILE_CONTENT_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileEncodingError(path, underlying_error)
¶
Bases: UserAccountsFileContentError
Raised when the user accounts file's bytes cannot be decoded as UTF-8.
Pinning the encoding on the read removes the case where the file was written as UTF-8 elsewhere and read back under a different platform default, but not this one, where the bytes are not valid UTF-8 under any reading.
There is no encoding counterpart on the write path. The accounts are serialized with
json.dumps, whose default ensure_ascii=True escapes every non-ASCII character, so
the text handed to the encoder is always pure ASCII and cannot fail to encode.
code = 'USER_ACCOUNTS_FILE_ENCODING_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileJSONError(path)
¶
Bases: UserAccountsFileContentError
Raised when the user accounts file does not contain valid JSON data.
code = 'USER_ACCOUNTS_FILE_JSON_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileSchemaError(path, validation_error_message)
¶
Bases: UserAccountsFileContentError
Raised when the user accounts file does not conform to the expected schema.
Covers the shape of the file as a whole and of every account entry in it: a top level value that is not an array, an entry missing a required field, an empty username or password, and an entry carrying a field the schema does not define.
code = 'USER_ACCOUNTS_FILE_SCHEMA_ERROR'
class-attribute
instance-attribute
¶
UserAccountsFileDuplicateUsernamesError(path, duplicate_username)
¶
Bases: UserAccountsFileContentError
Raised when the user accounts file contains multiple user account entries with the same username.
code = 'USER_ACCOUNTS_FILE_DUPLICATE_USERNAMES_ERROR'
class-attribute
instance-attribute
¶
UserAccountAuthenticationError()
¶
Bases: UserAccountsServiceError
Raised when a user account fails to authenticate due to invalid credentials.
code = 'USER_ACCOUNT_AUTHENTICATION_ERROR'
class-attribute
instance-attribute
¶
UserAccountManagementError(message='', detail=None)
¶
Bases: UserAccountsServiceError
Base exception for all errors that occur during user account creation or modification operations.
code = 'USER_ACCOUNT_MANAGEMENT_ERROR'
class-attribute
instance-attribute
¶
UserAccountUsernameAlreadyExistsError(message='', detail=None)
¶
Bases: UserAccountManagementError
Raised when attempting to create or modify a user account with a username that is already in use by another user account.
code = 'USER_ACCOUNT_USERNAME_ALREADY_EXISTS_ERROR'
class-attribute
instance-attribute
¶
EmptyUserAccountUsernameError(message='', detail=None)
¶
Bases: UserAccountManagementError
Raised when attempting to create or modify a user account with an empty username.
code = 'EMPTY_USER_ACCOUNT_USERNAME_ERROR'
class-attribute
instance-attribute
¶
EmptyUserAccountPasswordError(message='', detail=None)
¶
Bases: UserAccountManagementError
Raised when attempting to create or modify a user account with an empty password.
code = 'EMPTY_USER_ACCOUNT_PASSWORD_ERROR'
class-attribute
instance-attribute
¶
InvalidUserAccountRoleError(message='', detail=None)
¶
Bases: UserAccountManagementError
Raised when attempting to create or modify a user account with an invalid role. Valid roles are 'ADMIN', 'OPERATOR', or 'SPECTATOR'.