kdbxtool.exceptions¶
Custom exception hierarchy for kdbxtool.
This module provides a rich exception hierarchy for better error handling and user feedback. All exceptions inherit from KdbxError.
- Exception Hierarchy:
KdbxError (base) ├── FormatError │ ├── InvalidSignatureError │ ├── UnsupportedVersionError │ └── CorruptedDataError ├── CryptoError │ ├── DecryptionError │ ├── AuthenticationError │ ├── KdfError │ ├── UnknownCipherError │ └── TwofishNotAvailableError ├── CredentialError │ ├── InvalidPasswordError │ ├── InvalidKeyFileError │ ├── MissingCredentialsError │ └── YubiKeyError │ ├── YubiKeyNotFoundError │ ├── YubiKeySlotError │ ├── YubiKeyTimeoutError │ └── YubiKeyNotAvailableError └── DatabaseError
├── EntryNotFoundError └── GroupNotFoundError
- Security Note:
Exception messages are designed to avoid leaking sensitive information. They provide enough context for debugging without exposing secrets.
Exceptions
|
HMAC or integrity verification failed. |
Database file is corrupted or truncated. |
|
Error with database credentials. |
|
Error in cryptographic operations. |
|
Error in database operations. |
|
|
Failed to decrypt database content. |
|
Entry not found in database. |
Error in KDBX file format or structure. |
|
|
Group not found in database. |
|
Invalid or missing keyfile. |
|
Invalid or missing password. |
Invalid KDBX file signature (magic bytes). |
|
|
Invalid or malformed XML payload. |
KDBX3 database requires explicit upgrade confirmation. |
|
Base exception for all kdbxtool errors. |
|
Error in key derivation function. |
|
|
Error during database merge operation. |
No credentials provided. |
|
Twofish cipher requested but oxifish package not installed. |
|
|
Unknown or unsupported cipher algorithm. |
|
Unsupported KDBX version. |
Error communicating with YubiKey. |
|
YubiKey support requested but yubikey-manager not installed. |
|
|
No YubiKey detected. |
|
YubiKey slot not configured for HMAC-SHA1. |
|
YubiKey operation timed out. |
- exception kdbxtool.exceptions.KdbxError[source]¶
Bases:
ExceptionBase exception for all kdbxtool errors.
All exceptions raised by kdbxtool inherit from this class, making it easy to catch all library-specific errors.
- exception kdbxtool.exceptions.FormatError[source]¶
Bases:
KdbxErrorError in KDBX file format or structure.
Raised when the file doesn’t conform to the KDBX specification.
- exception kdbxtool.exceptions.InvalidSignatureError[source]¶
Bases:
FormatErrorInvalid KDBX file signature (magic bytes).
The file doesn’t start with the expected KDBX magic bytes, indicating it’s not a valid KeePass database file.
- exception kdbxtool.exceptions.UnsupportedVersionError(version_major, version_minor)[source]¶
Bases:
FormatErrorUnsupported KDBX version.
The file uses a KDBX version that this library doesn’t support.
- exception kdbxtool.exceptions.CorruptedDataError[source]¶
Bases:
FormatErrorDatabase file is corrupted or truncated.
The file structure is invalid, possibly due to incomplete download, disk corruption, or other data integrity issues.
- exception kdbxtool.exceptions.CryptoError[source]¶
Bases:
KdbxErrorError in cryptographic operations.
Base class for all cryptographic errors including encryption, decryption, and key derivation.
- exception kdbxtool.exceptions.DecryptionError(message='Decryption failed')[source]¶
Bases:
CryptoErrorFailed to decrypt database content.
This typically indicates wrong credentials (password/keyfile), but the message is kept generic to avoid confirming which credential component is incorrect.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.AuthenticationError(message='Authentication failed - wrong credentials or corrupted data')[source]¶
Bases:
CryptoErrorHMAC or integrity verification failed.
The database’s authentication code doesn’t match, indicating either wrong credentials or data tampering.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.KdfError[source]¶
Bases:
CryptoErrorError in key derivation function.
Problems with KDF parameters, unsupported KDF types, or KDF computation failures.
- exception kdbxtool.exceptions.UnknownCipherError(cipher_uuid)[source]¶
Bases:
CryptoErrorUnknown or unsupported cipher algorithm.
The database uses a cipher that this library doesn’t recognize.
- Parameters:
cipher_uuid (bytes)
- Return type:
None
- exception kdbxtool.exceptions.TwofishNotAvailableError[source]¶
Bases:
CryptoErrorTwofish cipher requested but oxifish package not installed.
The database uses Twofish encryption, which requires the optional oxifish package. Install it with: pip install kdbxtool[twofish]
- Return type:
None
- exception kdbxtool.exceptions.CredentialError[source]¶
Bases:
KdbxErrorError with database credentials.
Base class for credential-related errors. Messages are kept generic to avoid information disclosure about which credential component is incorrect.
- exception kdbxtool.exceptions.InvalidPasswordError(message='Invalid password')[source]¶
Bases:
CredentialErrorInvalid or missing password.
Note: This is only raised when we can definitively determine the password is wrong without revealing information about other credential components.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.InvalidKeyFileError(message='Invalid keyfile')[source]¶
Bases:
CredentialErrorInvalid or missing keyfile.
The keyfile is malformed, has wrong format, or failed hash verification.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.MissingCredentialsError[source]¶
Bases:
CredentialErrorNo credentials provided.
At least one credential (password or keyfile) is required to open or create a database.
- Return type:
None
- exception kdbxtool.exceptions.YubiKeyError[source]¶
Bases:
CredentialErrorError communicating with YubiKey.
Base class for YubiKey-related errors. These occur during challenge-response authentication with a hardware YubiKey.
- exception kdbxtool.exceptions.YubiKeyNotFoundError(message=None)[source]¶
Bases:
YubiKeyErrorNo YubiKey detected.
No YubiKey device was found connected to the system. Ensure the YubiKey is properly inserted.
- Parameters:
message (str | None)
- Return type:
None
- exception kdbxtool.exceptions.YubiKeySlotError(slot)[source]¶
Bases:
YubiKeyErrorYubiKey slot not configured for HMAC-SHA1.
The specified slot on the YubiKey is not configured for HMAC-SHA1 challenge-response authentication.
- Parameters:
slot (int)
- Return type:
None
- exception kdbxtool.exceptions.YubiKeyTimeoutError(timeout_seconds=15.0)[source]¶
Bases:
YubiKeyErrorYubiKey operation timed out.
The YubiKey operation timed out, typically because touch was required but not received within the timeout period.
- Parameters:
timeout_seconds (float)
- Return type:
None
- exception kdbxtool.exceptions.YubiKeyNotAvailableError[source]¶
Bases:
YubiKeyErrorYubiKey support requested but yubikey-manager not installed.
The yubikey-manager package is required for YubiKey challenge-response authentication. Install it with: pip install kdbxtool[yubikey]
- Return type:
None
- exception kdbxtool.exceptions.DatabaseError[source]¶
Bases:
KdbxErrorError in database operations.
Base class for errors that occur during database manipulation after successful decryption.
- exception kdbxtool.exceptions.EntryNotFoundError(message='Entry not found')[source]¶
Bases:
DatabaseErrorEntry not found in database.
The requested entry doesn’t exist or was not found in the specified location.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.GroupNotFoundError(message='Group not found')[source]¶
Bases:
DatabaseErrorGroup not found in database.
The requested group doesn’t exist or was not found in the database hierarchy.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.InvalidXmlError(message='Invalid KDBX XML structure')[source]¶
Bases:
DatabaseErrorInvalid or malformed XML payload.
The decrypted XML content doesn’t conform to the expected KDBX XML schema.
- Parameters:
message (str)
- Return type:
None
- exception kdbxtool.exceptions.Kdbx3UpgradeRequired[source]¶
Bases:
DatabaseErrorKDBX3 database requires explicit upgrade confirmation.
When saving a KDBX3 database to its original file, explicit confirmation is required since the save will upgrade it to KDBX4. Use save(allow_upgrade=True) to confirm the upgrade.
- Return type:
None
- exception kdbxtool.exceptions.MergeError(message='Merge operation failed')[source]¶
Bases:
DatabaseErrorError during database merge operation.
Raised when a merge operation fails due to incompatible databases, invalid state, or other merge-specific issues.
- Parameters:
message (str)
- Return type:
None