Skip to content

Exceptions

Provides the typed exception classes and the error translator of gllm-datastore.

BaseDatastoreError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseError

Root of the normalized errors raised by gllm-datastore.

This class is abstract and is never raised directly. Every concrete subclass defines its own code (GLLM-DS-<NAME>) and default_message.

Attributes:

Name Type Description
code str | None

Stable error code. Defined by each concrete subclass.

default_message str | None

Message used when no message is given. Defined by each concrete subclass.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

BatchingError(errors)

Bases: BaseDatastoreError

Raised when one or more errors occur during batch processing.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-BATCHING.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

errors list[Exception]

The exceptions encountered during batch processing.

Initializes a new instance of the BatchingError class.

Parameters:

Name Type Description Default
errors list[Exception]

The exceptions encountered during batch processing.

required

BulkFailure

Bases: TypedDict

One failed item of a batch operation.

Attributes:

Name Type Description
index int | None

Position of the item in the original batch, or None when the backend does not report it.

id str | None

The item id, when the backend reports one.

error_class str

Name of the typed class the failure maps to, such as DatastoreOverloadedError.

status int | None

The status code the backend reported for the item.

error_type str | None

The backend error code or type, such as circuit_breaking_exception. Never the backend's reason text, which can echo rejected document values.

retryable bool

Whether the mapped class is retryable.

CacheEvictionCloseError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when the cache eviction manager fails to close or stop.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-CACHE-EVICTION-CLOSE.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

CacheEvictionStartError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when the cache eviction manager fails to start.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-CACHE-EVICTION-START.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

DatastoreAuthError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: DatastoreRuntimeError

Raised when the datastore rejects the credentials or the permissions of the caller.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-AUTH.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

recovery RecoveryInfo

Not retryable. Retrying with the same credentials fails again.

DatastoreBulkError(message=None, *, failures=None, **kwargs)

Bases: DatastoreRuntimeError

Raised when some records of a batch operation fail.

One error carries every failed item. It is retryable only when every failed item is: indexing by id is idempotent, so the whole batch can be retried. Otherwise the caller retries only the retryable entries of failures. Treat failures like request data: its ids are caller-supplied.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-BULK.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

recovery RecoveryInfo

Retryable only when every failed item is retryable.

failures list[BulkFailure]

Every failed item, in the order the backend reported them.

Initializes a new instance of the DatastoreBulkError class.

Parameters:

Name Type Description Default
message str | None

The message. Defaults to None.

None
failures list[BulkFailure] | None

Every failed item. Defaults to None, which means no failures. The default lets pickle rebuild the error with the message alone and restore the rest from its state.

None
**kwargs Any

Passed to DatastoreRuntimeError. recovery is ignored: it is derived from failures.

{}

DatastoreConnectionError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: DatastoreRuntimeError, ConnectionError

Raised when a datastore connection cannot be established or is lost.

Existing except ConnectionError and except DatastoreConnectionError clauses keep matching. Clauses that catch RuntimeError or DatastoreRuntimeError match too, which keeps handlers working for the connection failures that used to surface as DatastoreRuntimeError.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-CONNECTION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

recovery RecoveryInfo

Retryable.

DatastoreDebugInfo

Bases: DebugInfo

Structured internal detail attached to the errors raised by gllm-datastore.

Extends DebugInfo with the keys specific to datastore errors. This is a type-level contract only.

Attributes:

Name Type Description
class_name str

Name of the exception class. Always present.

error_type str

Type name of the original error, when one was caught.

original_message str

Message of the original error, when one was caught.

traceback str

Formatted traceback of the original error, when one was caught.

chunk_id str

ID of the chunk being processed, when the error relates to a chunk.

stage str

Stage of the operation that failed, such as content or metadata.

failed_items list[dict[str, str]]

Items that failed in a batch operation, when applicable.

fields list[str]

Names of the fields that failed, when applicable.

capability str

Name of the capability involved, when applicable.

datastore_class str

Name of the datastore class involved, when applicable.

DatastoreErrorTranslator(capability, datastore_class, strategy=None)

Translates a raw backend exception into a typed datastore error.

The strategy resolves the raw error to a typed error class or factory. An error the strategy does not map becomes exactly DatastoreRuntimeError. NotImplementedError and every BaseError pass through unchanged: no wrap precedes the translator, so there is nothing to reclassify.

A mapped class or factory that cannot be built with the standard arguments is replaced by DatastoreRuntimeError. A factory is called like a class, with message, debug_info and original_error, and receives message=None, so it owns its message. Subclasses can override _build to change how errors are constructed.

Attributes:

Name Type Description
strategy DatastoreExtractionStrategy

The strategy that maps raw errors to typed error classes.

Initializes a new instance of the DatastoreErrorTranslator class.

Parameters:

Name Type Description Default
capability str

Name of the capability whose operations are translated, such as fulltext.

required
datastore_class str

Name of the datastore class that raised the error.

required
strategy DatastoreExtractionStrategy | None

The strategy that maps raw errors to typed error classes. Defaults to None, which maps nothing so every error becomes DatastoreRuntimeError.

None

__call__(error)

Translates an error without an operation, so the translator fits RetryConfig.error_translators.

Parameters:

Name Type Description Default
error Exception

The error raised by an operation.

required

Returns:

Name Type Description
Exception Exception

The typed error, or error itself when it must not change.

translate(error, *, operation=None, target=None)

Translates an error.

When the strategy resolves nothing, or the resolved class cannot be built with the standard arguments, the result is a DatastoreRuntimeError.

Parameters:

Name Type Description Default
error Exception

The error raised by an operation.

required
operation str | None

The failed operation as a phrase, such as Failed to create records. Without it the message is the class default. Defaults to None.

None
target str | None

The object the operation was acting on, such as table 'docs'. Defaults to None.

None

Returns:

Name Type Description
Exception Exception

The typed error, or error itself when it must not change.

translate_bulk(items, *, operation=None)

Builds one aggregate error for the failed items of a batch.

Backend reason text is never read, stored or passed on, because it can echo rejected document values. The error carries no original_error and no ids in debug_info; ids appear only in failures.

Parameters:

Name Type Description Default
items list[tuple[int | None, Any]]

Each failed item exactly as the backend reported it, with its position in the original batch, or None when the backend does not report one.

required
operation str | None

The failed operation as a phrase. Defaults to None.

None

Returns:

Name Type Description
DatastoreBulkError DatastoreBulkError

The error. Its failures lists every item and its recovery is retryable only when every item is.

DatastoreNotFoundError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: DatastoreRuntimeError

Raised when the datastore index, collection, table, bucket, or key does not exist.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-NOT-FOUND.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

recovery RecoveryInfo

Not retryable. The resource must be created or its name fixed first.

DatastoreNotImplementedError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, NotImplementedError

Raised when a datastore operation is not implemented or not supported.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-NOT-IMPLEMENTED.

default_message str

Default message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

DatastoreOverloadedError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: DatastoreRuntimeError

Raised when the datastore is temporarily out of capacity and rejects the request.

Covers memory pressure, rejected executions, connection or session limits, and rate limits.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-OVERLOADED.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

recovery RecoveryInfo

Retryable. retry_after_seconds is set when the backend reports one.

DatastoreRuntimeError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when a datastore operation fails at runtime.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-RUNTIME.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

DatastoreTypeError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, TypeError

Raised when a value passed to a datastore has an unsupported type.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-TYPE.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

DatastoreValueError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, ValueError

Raised when a datastore, credential, or capability configuration is invalid.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-VALIDATION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

DecryptionError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when decrypting the content or metadata of a chunk fails.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-DECRYPTION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail, such as chunk_id, stage, and fields.

EmbeddingInvocationError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when embedding invocation still fails after all retries.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-EMBEDDING-INVOCATION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

EncryptionError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, RuntimeError

Raised when encrypting the content or metadata of a chunk fails.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-ENCRYPTION.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail, such as chunk_id, stage, and fields.

OpenBaoAuthenticationError(message=None, *, debug_info=None, recovery=None, original_error=None)

Bases: BaseDatastoreError, ValueError

Raised when authenticating with OpenBao fails.

Attributes:

Name Type Description
code str

Stable error code, GLLM-DS-OPENBAO-AUTH.

default_message str

Message used when no message is given.

message str

The message of this error.

debug_info DatastoreDebugInfo

Structured internal detail about this error.

__getattr__(name)

Lazily load the error translator to keep this package free of import cycles.

Parameters:

Name Type Description Default
name str

The attribute name being accessed.

required

Returns:

Name Type Description
Any Any

The requested attribute.

Raises:

Type Description
AttributeError

If the attribute is not a lazily loaded export.