imednet.errors package

Exception hierarchy.

Submodules

imednet.errors.api module

API-level errors.

exception imednet.errors.api.ApiError[source]

Bases: ImednetError

Raised for generic API errors (non-2xx HTTP status codes).

status_code

HTTP status code returned by the API.

response

Parsed JSON or raw text of the error response.

code

Upstream API error code, if present.

status

Upstream API status string, if present.

description

Upstream API error description, if present.

field

Offending request field details, if present.

errors

Normalized list of structured error items, if present.

__init__(response, status_code=None, *, diagnostic_context=None)[source]

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.AuthenticationError[source]

Bases: ApiError

Raised when authentication to the API fails (HTTP 401).

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.AuthorizationError[source]

Bases: ApiError

Raised when access to the API is forbidden (HTTP 403).

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.ConflictError[source]

Bases: ApiError

Raised for HTTP 409 conflict errors.

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.ForbiddenError[source]

Bases: AuthorizationError

Raised for HTTP 403 forbidden errors.

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.NotFoundError[source]

Bases: ApiError

Raised when a requested resource is not found (HTTP 404).

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.RateLimitError[source]

Bases: ApiError

Raised when the API rate limit is exceeded (HTTP 429).

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.ServerError[source]

Bases: ApiError

Raised when the API returns a server error (HTTP 5xx).

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.api.UnauthorizedError[source]

Bases: AuthenticationError

Raised for HTTP 401 unauthorized errors.

__init__(response, status_code=None, *, diagnostic_context=None)

Initialize an API error.

Parameters:
  • response (dict[str, Any] | str | Any) – The error response from the API.

  • status_code (int | None) – Optional HTTP status code.

  • diagnostic_context (DiagnosticContext | None) – Optional HTTP diagnostic context.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.base module

Base errors.

class imednet.errors.base.DiagnosticContext[source]

Bases: object

Immutable HTTP and transport diagnostic metadata attached to SDK errors.

method: str | None = None
url: str | None = None
retry_after: float | None = None
attempt_count: int | None = None
cause_type: str | None = None
exception imednet.errors.base.ImednetError[source]

Bases: Exception

Base exception for all iMednet SDK errors.

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)[source]

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.client module

Client-side errors.

exception imednet.errors.client.ClientError[source]

Bases: ImednetError

Raised for client-side errors (validation, configuration, misuse).

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)[source]

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.client.PaginationError[source]

Bases: ClientError

Raised when pagination metadata is malformed or inconsistent.

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.export module

Export-sink error types.

exception imednet.errors.export.ExportBatchError[source]

Bases: ExportError

Raised when a single batch write fails after all retries are exhausted.

__init__(message, *, batch_id)[source]

Initialize an export batch error.

Parameters:
  • message (str) – The error message.

  • batch_id (str) – The ID of the failed batch.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.export.ExportConfigurationError[source]

Bases: ExportError, ValueError

Raised when a sink is misconfigured (missing credentials, invalid parameters).

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.export.ExportError[source]

Bases: ImednetError

Raised when an export sink cannot write a batch or finalize a destination.

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.network module

Network errors.

exception imednet.errors.network.CircuitBreakerError[source]

Bases: ImednetError

Raised when the circuit breaker is open and a request is blocked.

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.network.RequestError[source]

Bases: ImednetError

Raised when an HTTP transport request fails.

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.orchestration module

Exceptions raised by the MultiStudyOrchestrator engine.

exception imednet.errors.orchestration.FilterConflictError[source]

Bases: OrchestratorError

Raised when both whitelist and blacklist are non-empty simultaneously.

The whitelist and blacklist filters are mutually exclusive operations. Providing both simultaneously creates ambiguous behavior and is rejected at validation time before any study resolution occurs.

Example:

# This raises FilterConflictError — a study key cannot be in both:
orchestrator.execute_pipeline(
    my_func,
    whitelist={"STUDY-A", "STUDY-B"},
    blacklist={"STUDY-C"},
)
__init__(whitelist, blacklist)[source]

Initialize a filter conflict error.

Parameters:
  • whitelist (set[str]) – The provided study key whitelist.

  • blacklist (set[str]) – The provided study key blacklist.

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.orchestration.OrchestratorError[source]

Bases: ImednetError

Base exception for all orchestration-layer failures.

Raised when the MultiStudyOrchestrator encounters a structural or configuration error that prevents pipeline execution from starting.

Individual per-study runtime failures are NOT raised as exceptions — they are captured in the OrchestratorResult result matrix with status="FAILED".

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.plugin module

Plugin-related errors.

exception imednet.errors.plugin.PluginLoadError[source]

Bases: ImednetError

Raised when a plugin fails to load or does not satisfy the PluginProtocol.

__init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)

Initialize the error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (Any) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

imednet.errors.registry module

Registry for HTTP status code to error class mappings.

imednet.errors.registry.get_error_class(status_code, response_body=None)[source]

Get error class for status code and response payload.

Routes HTTP 400, 401, and 403 directly to BadRequestError, UnauthorizedError, and ForbiddenError regardless of nested error codes, then inspects nested metadata.error (dict or list), metadata.status, and legacy top-level keys for envelope or other status codes, and finally falls back to HTTP status mappings. Defaults to generic ApiError for unmapped client/server errors.

Parameters:
  • status_code (int) –

  • response_body (Any) –

Return type:

type[ApiError]

imednet.errors.validation module

Validation errors.

exception imednet.errors.validation.BadRequestError[source]

Bases: ValidationError

Raised for HTTP 400 bad requests.

__init__(response='', status_code=400, *, validation_report=None, diagnostic_context=None)[source]

Initialize HTTP 400 bad request error.

Parameters:
  • response (dict[str, Any] | str | Any) –

  • status_code (int | None) –

  • validation_report (Any | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.ConfigurationError[source]

Bases: ClientError, ValueError

Raised when required SDK/client configuration is missing.

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.EvaluationError[source]

Bases: ClientError

Raised when expression evaluation fails.

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.PathTraversalValidationError[source]

Bases: ClientError

Raised when a partition key contains unsafe path content.

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.RestrictedEvaluationError[source]

Bases: EvaluationError

Raised when an expression attempts forbidden operations or syntax.

__init__(message='', status_code=400, code=None, status='client_error', *, diagnostic_context=None)

Initialize the client error.

Parameters:
  • message (str) –

  • status_code (int | None) –

  • code (int | None) –

  • status (str | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.UnknownVariableTypeError[source]

Bases: ValidationError

Raised when an unrecognized variable type is encountered.

__init__(response='', status_code=None, *, validation_report=None, diagnostic_context=None)

Initialize validation error, preserving upstream status when present.

Parameters:
  • response (dict[str, Any] | str | Any) –

  • status_code (int | None) –

  • validation_report (Any | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.

exception imednet.errors.validation.ValidationError[source]

Bases: ClientError, ApiError

Raised when client-side validation fails or a request is malformed.

__init__(response='', status_code=None, *, validation_report=None, diagnostic_context=None)[source]

Initialize validation error, preserving upstream status when present.

Parameters:
  • response (dict[str, Any] | str | Any) –

  • status_code (int | None) –

  • validation_report (Any | None) –

  • diagnostic_context (DiagnosticContext | None) –

Return type:

None

property attempt_count: int | None

Return the number of attempts executed before failure, if present.

property cause_type: str | None

Return the underlying exception class name, if present.

property field_attribute: str | None

Return the offending field or variable name from field, if present.

property field_value: Any

Return the redacted offending field value from field, if present.

property method: str | None

Return the HTTP method from diagnostic_context, if present.

property retry_after: float | None

Return the parsed Retry-After delay in seconds, if present.

property url: str | None

Return the sanitized request URL from diagnostic_context, if present.