Skip to main content

sasvi.errors

Public exception hierarchy for the sasvi SDK.

Every error raised by handwritten SDK code derives from SVIError. Catch the base class to handle any SDK failure; catch one of the typed subclasses (NotFoundError, ConflictError, ValidationError, or a domain-specific class like WorkflowNotFoundError) to branch precisely.

Transport failures are part of that contract. A request that never produced a usable response raises ServiceUnreachableError, NetworkError, TLSError, DeadlineExceededError or MalformedResponseError, each keeping the originating httpx2 exception as __cause__. Before resending a write after a NetworkError, check outcome_unknown: the server may already have applied it.

Errors carry structured data:

  • status_code: HTTP status returned by the upstream service, when known.
  • error_code: Server-defined error code (e.g. "VI-1234"), when known.
  • details: Detail strings extracted from the error payload.
  • remediation: User-facing remediation hint when the server provided one.
  • raw: The upstream error for advanced inspection: the generated error model when the generated layer parsed one, else the response body bytes.

A caller that branches on failure can write::

try: alert = client.alerts.get(alert_id="alert-1") if alert is not None: alert.disposition(resolution_code="FALSE_POSITIVE") except DispositionPromptRequiredError as exc: prompt_user(missing=exc.missing) except ConflictError as exc: retry_after_refresh() except SVIError as exc: log.exception("SVI failure (status=%s, code=%s)", exc.status_code, exc.error_code)

SVIError Objects​

class SVIError(Exception)

Base for every error raised by the sasvi SDK.

Catch this to handle any SDK failure uniformly. Prefer catching a typed subclass when you can act on a specific failure mode.

status_code​

error_code​

details​

remediation​

raw​

NotFoundError Objects​

class NotFoundError(SVIError)

Marker for missing-resource failures (HTTP 404 or equivalent).

ConflictError Objects​

class ConflictError(SVIError)

Marker for state-conflict or optimistic-concurrency failures (HTTP 409 or 412).

ValidationError Objects​

class ValidationError(SVIError)

Marker for input-validation failures rejected by the SDK or server.

TransientError Objects​

class TransientError(SVIError)

Marker for retryable transport- or server-side failures.

ResponseTooLargeError Objects​

class ResponseTooLargeError(SVIError)

Raised when a response body passes SVIConfig.max_response_bytes.

The body is read in chunks and counted, so the cap is a read budget rather than a Content-Length assertion. A chunked response, a missing or dishonest Content-Length, and a compressed body that expands past the cap are all bounded; an honestly declared oversize response is rejected before its body is read at all. A size violation is never retried.

NetworkError Objects​

class NetworkError(_TransportFailure, TransientError)

Raised when a request failed before a complete response arrived.

The originating httpx2 exception is kept as __cause__. Inspect outcome_unknown before resending a non-idempotent request: a failure after the request left the client may still have been applied server-side.

Arguments:

  • message - Human-readable failure description.
  • outcome_unknown - Whether the server may still have applied the request.
  • **kwargs - Shared transport fields (method, url, attempts) and the structured SVIError fields.

outcome_unknown​

result​

Partial result of the multi-step operation that failed, when there is one.

ServiceUnreachableError Objects​

class ServiceUnreachableError(NetworkError)

Raised when the service could not be reached at all.

DNS, connection and proxy failures never reached the server, so NetworkError.outcome_unknown is False and resending is safe.

Arguments:

  • message - Human-readable failure description.
  • **kwargs - Fields accepted by NetworkError.

TLSError Objects​

class TLSError(_TransportFailure)

Raised when TLS negotiation or certificate validation failed.

TLS failures are never retried: they are the signal an operator needs about certificate trust, pinning, or an active downgrade attempt. Not a TransientError.

Arguments:

  • message - Human-readable failure description.
  • **kwargs - Shared transport fields and structured SVIError fields.

DeadlineExceededError Objects​

class DeadlineExceededError(_TransportFailure, TransientError)

Raised when request_deadline_seconds ran out.

Arguments:

  • message - Human-readable failure description.
  • deadline_seconds - The configured budget, in seconds.
  • outcome_unknown - Whether the server may still have applied the request.
  • **kwargs - Shared transport fields and structured SVIError fields.

deadline_seconds​

outcome_unknown​

ClientClosedError Objects​

class ClientClosedError(SVIError)

Raised when a request is made through a client that was closed.

Closing is final, so this is not a TransientError. Handles kept from a closed client, such as a Document, raise it too. Build a new sasvi.SVIClient and fetch the object again.

EventLoopChangedError Objects​

class EventLoopChangedError(SVIError)

Raised when an async client is used on a second event loop.

The async transports hold connections that belong to the event loop they were first used on. Each asyncio.run() call starts a new loop, so a client reused across two of them cannot send. Create one sasvi.SVIClient per event loop, or make every call inside one asyncio.run().

MalformedResponseError Objects​

class MalformedResponseError(SVIError)

Raised when a response body could not be read as the documented shape.

A successful status whose body is not decodable JSON, or does not match the generated model, is a failure of the response contract rather than a successful call. raw carries the body bytes for triage.

result​

Partial result of the multi-step operation that failed, when there is one.

is_tls_failure​

def is_tls_failure(exc: BaseException) -> bool

Return True when a TLS failure is anywhere in an exception's chain.

HTTPX wraps a certificate or handshake failure, so the ssl.SSLError is rarely the exception a caller catches. The walk follows __cause__ and __context__, stops on a cycle, and looks at no more than 50 links.

Arguments:

  • exc - The exception to inspect.

Returns:

True if any link is a TLSError or an ssl.SSLError.

SVIConfigurationError Objects​

class SVIConfigurationError(SVIError)

Raised when local SDK configuration is missing or malformed.

AuthConfigurationError Objects​

class AuthConfigurationError(SVIConfigurationError)

Raised when authentication configuration is missing or invalid.

AuthServiceUnavailableError Objects​

class AuthServiceUnavailableError(AuthConfigurationError, TransientError)

Raised when SAS Logon answers a token request with 408, 429 or 5xx.

The credentials were not rejected: the token endpoint is down or overloaded, for example during a Viya rolling restart. It stays an AuthConfigurationError so existing handlers still catch it, and it is a TransientError so retry logic can act on it. The SDK has already retried a client-credentials or password grant twice. It is not a NetworkError, which the request loop would retry a second time. The response body is never kept, because it can echo the submitted grant.

Arguments:

  • message - Human-readable failure description.
  • retry_after - Seconds SAS Logon asked the caller to wait, when it sent a Retry-After header.
  • **kwargs - The structured SVIError fields, status_code among them.

retry_after​

InvalidBaseURLError Objects​

class InvalidBaseURLError(SVIConfigurationError, ValueError)

Raised when a base URL, service URL, or custom target URL is refused.

Covers an unsupported scheme, credentials embedded in the URL, and plaintext http:// to a non-loopback host without the insecure opt-in.

AuthInputError Objects​

class AuthInputError(AuthConfigurationError, ValueError)

Raised when an auth flow lacks an input it needs to proceed.

Covers a missing SAS Logon URL, a missing authorization code, a missing refresh token, and a token response the provider cannot store.

AdminOperationError Objects​

class AdminOperationError(SVIError)

Raised when an admin/configuration operation fails.

AdminNotFoundError Objects​

class AdminNotFoundError(AdminOperationError, NotFoundError)

Raised when an admin/configuration resource is not found (HTTP 404).

AdminConflictError Objects​

class AdminConflictError(AdminOperationError, ConflictError)

Raised when an admin/configuration operation conflicts (HTTP 409 or 412).

ConfigurationImportError Objects​

class ConfigurationImportError(AdminOperationError)

Raised when a multi-component configuration import fails.

Arguments:

  • message - Human-readable failure description.
  • result - Partial import result, when available.
  • outcome_unknown - Whether the failed step may still have been applied.

result​

outcome_unknown​

DocumentOperationError Objects​

class DocumentOperationError(SVIError)

Raised when a document-backed operation fails.

DocumentNotFoundError Objects​

class DocumentNotFoundError(DocumentOperationError, NotFoundError)

Raised when a Data Hub document/resource is not found (HTTP 404).

DocumentConflictError Objects​

class DocumentConflictError(DocumentOperationError, ConflictError)

Raised when a Data Hub operation conflicts (HTTP 409 or 412).

A 412 means the If-Match precondition the SDK sent no longer matches the server's current version: refresh the resource and retry the edit.

InvalidDocumentReferenceError Objects​

class InvalidDocumentReferenceError(DocumentOperationError, TypeError)

Raised when a value cannot be interpreted as a document reference.

RelationshipAmbiguousError Objects​

class RelationshipAmbiguousError(DocumentOperationError)

Raised when a relationship type cannot be uniquely resolved.

BulkOperationError Objects​

class BulkOperationError(DocumentOperationError)

Raised when a bulk Data Hub operation failed at the request or row level.

Arguments:

  • message - Human-readable failure description.
  • failures - Per-row results whose error was set. Empty for request-level failures. Each element is a BulkOperationResult / BulkLinkOperationResult from sasvi.documents.

failures​

BulkRequestError Objects​

class BulkRequestError(BulkOperationError)

Raised when a bulk request itself failed, not just some of its rows.

A chunked upsert used to lose everything it had already done: the rows from earlier chunks lived in a local list that the exception unwound past, so a caller could neither report what had been created nor resume without risking duplicates.

Arguments:

  • message - Human-readable failure description.
  • completed - Result rows the server confirmed before the failure.
  • input_offset - Index of the first input that was not confirmed.
  • item_count - Number of inputs in the failed request; 0 when the failure happened before anything was sent.
  • outcome_unknown - Whether the failed request may still have been applied.
  • failures - Per-row failures inside completed.
  • status_code - Upstream HTTP status, when known.
  • error_code - Server-defined error code, when known.
  • details - Detail strings extracted from the error payload.
  • remediation - User-facing remediation hint, when provided.
  • raw - Raw upstream payload, for advanced inspection.

completed​

input_offset​

item_count​

outcome_unknown​

AlertOperationError Objects​

class AlertOperationError(DocumentOperationError)

Raised when an alert-specific handwritten operation fails.

AlertNotFoundError Objects​

class AlertNotFoundError(AlertOperationError, NotFoundError)

Raised when an alert is not found (HTTP 404).

DispositionPromptRequiredError Objects​

class DispositionPromptRequiredError(AlertOperationError, ValidationError)

Raised when a disposition requires fields the caller did not supply.

Inspect missing for the list of field names that need to be passed on the retry call.

disposition_id​

missing​

AlertCreationFailedError Objects​

class AlertCreationFailedError(AlertOperationError)

Raised when alert creation did not produce an identifiable result.

AlertConflictError Objects​

class AlertConflictError(AlertOperationError, ConflictError)

Raised when the Alerts service answers 409 or 412.

A 409 means the write conflicts with the alert's current state (another user holds the checkout, the disposition was already applied); a 412 means the version the request carried is stale. Refresh the alert and decide whether to reapply.

AlertNotCheckedOutError Objects​

class AlertNotCheckedOutError(AlertConflictError)

Raised when an action requires the alert to be checked out to the caller.

The SDK raises it before sending a write it knows the service would refuse, such as a productivity rating on an alert another user holds.

checkout_user_id​

SearchOperationError Objects​

class SearchOperationError(SVIError)

Raised when a SAND search operation fails.

InvalidSearchQueryError Objects​

class InvalidSearchQueryError(SearchOperationError, ValidationError)

Raised when the assembled search query was rejected as invalid.

InvalidSearchInputError Objects​

class InvalidSearchInputError(SearchOperationError, TypeError)

Raised when an input shape passed to the search builder is unsupported.

SearchScopeError Objects​

class SearchScopeError(SearchOperationError)

Raised when the search builder is invoked in an invalid context.

WorkflowOperationError Objects​

class WorkflowOperationError(SVIError)

Raised when a workflow-specific handwritten operation fails.

WorkflowNotFoundError Objects​

class WorkflowNotFoundError(WorkflowOperationError, NotFoundError)

Raised when a workflow definition or instance cannot be located.

WorkflowStateError Objects​

class WorkflowStateError(WorkflowOperationError, ConflictError)

Raised when a workflow operation is incompatible with the current state.

WorkflowDocumentUpdateError Objects​

class WorkflowDocumentUpdateError(WorkflowOperationError)

Raised when a task completed but its document update then failed.

WorkflowTask.complete(document_field_values=...) sends the completion first and writes the document fields second. Completion cannot be undone, so when the document write fails the task is already complete on the server.

Do not retry complete() after this error. The task is gone and the retry gets 404. Retry the document update instead, with task_id, document_type and document_id to find the target. The failure that stopped the update is chained as __cause__.

Arguments:

  • message - Human-readable failure description.
  • task_completed - Always True. The completion request succeeded.
  • task_id - Id of the task that completed.
  • document_type - Entity type name of the document that was not updated.
  • document_id - Id of the document that was not updated.
  • status_code - Upstream HTTP status of the failed update, when known.
  • error_code - Server-defined error code, when known.
  • details - Detail strings from the failed update.
  • remediation - User-facing remediation hint, when provided.
  • raw - Raw upstream error model, for advanced inspection.

task_completed​

task_id​

document_type​

document_id​

ReferenceListError Objects​

class ReferenceListError(SVIError)

Raised when a reference-list operation fails.

ReferenceListNotFoundError Objects​

class ReferenceListNotFoundError(ReferenceListError, NotFoundError)

Raised when a reference list cannot be located.

ReferenceListItemError Objects​

class ReferenceListItemError(ReferenceListError)

Raised when a reference-list item is malformed or rejected.

ReferenceListValidationError Objects​

class ReferenceListValidationError(ReferenceListError, ValidationError)

Raised when a reference-list payload fails validation.

ReferenceListConcurrentModificationError Objects​

class ReferenceListConcurrentModificationError(ReferenceListError,
ConflictError)

Raised when a reference-list change conflicts with concurrent modification.

IncompleteListingError Objects​

class IncompleteListingError(SVIError)

Raised when an exhaustive listing could not be finished.

The guards that keep a listing from spinning forever used to log a WARNING and return what they had, so a caller could not tell a complete result from a truncated one. A read-modify-write built on the short read would then delete everything it never saw.

Arguments:

  • message - Human-readable failure description.
  • reason - Why the walk stopped: "repeated_page" when the server stopped advancing, "page_cap" when the page ceiling was hit, "short_of_total" when the server ran out of rows before its own reported total, or "server_rejected_offset" when the service answered 400 or 422 for a page after the first.
  • label - The collection being listed.
  • partial - Items collected before the walk stopped. Empty when the caller consumed an iterator, which already holds them.
  • pages_fetched - Requests made before the walk stopped.
  • next_start - Offset the walk stopped at, for resuming.
  • server_total - The server's reported total, when it sent one.

reason​

label​

partial​

pages_fetched​

next_start​

server_total​

InsightsError Objects​

class InsightsError(SVIError)

Raised when an insights operation cannot be completed successfully.

InsightInputError Objects​

class InsightInputError(InsightsError, ValidationError, ValueError)

Raised when an insight cell builder is given input it cannot use.

A document that is neither a bound handle nor a mapping, a shorthand tuple of the wrong length, an endpoint that matches no document, or a result passed next to the documents it would be derived from. It is a ValueError as well, so an existing except ValueError still catches it.

PreviewMultiCallError Objects​

class PreviewMultiCallError(SVIError)

Raised when the previewed handwritten call fires more than one HTTP request.

The universal preview entry points (SVIClient.preview_next, SVIClient.preview) capture exactly one request. If a handwritten method issues multiple HTTP calls (e.g. bulk upsert loops, fetch-then-update flows), the second request triggers this error.

For multi-call methods, use the explicit *_preview method on the operation (which can preview the primary call deterministically), or refactor the call site to invoke the single underlying operation directly.

Note: because the captured first request returns a stand-in empty response under preview, a method that issues a second request only conditionally (e.g. a fallback when the first response is empty) can also raise this, even though against a real response it makes a single call. Such methods are best previewed via their explicit *_preview.

PreviewNotCapturedError Objects​

class PreviewNotCapturedError(SVIError)

Raised when a previewed call returned without firing any HTTP request.

The call ran to completion (no exception) but never touched the network: likely a no-op, a cache hit, or a method that does not wrap a generated endpoint at all. There's nothing to preview.

PreviewIncompleteError Objects​

class PreviewIncompleteError(SVIError)

Raised when the previewed call failed after a captured read.

The first request of the call was a read (GET, HEAD or OPTIONS), and the call then raised before building the request the caller asked about. Such a read is a prerequisite of the operation (entity metadata, a lock, an ETag) rather than the operation itself, so it is not returned as the preview. It stays reachable on captured.

Use the explicit *_preview method for the operation when one exists, or preview the single underlying API call directly.

Attributes:

  • captured - The read that was captured before the call failed.

ensure_admin_success​

def ensure_admin_success(result: ResultT | None,
*,
missing_is_none: bool = False) -> ResultT | None

Normalize a generated admin/configuration response into SDK behavior.

Arguments:

  • result - Generated client payload or error model.
  • missing_is_none - When True, a 404 response returns None instead of raising NotFoundError.

Returns:

The successful payload, or None for tolerated missing resources.

Raises:

  • AdminOperationError - When the payload represents a failed admin operation.
  • NotFoundError - When the upstream service returned 404 and missing_is_none is False.

ensure_datahub_success​

def ensure_datahub_success(result: ResultT | SasError | None,
*,
missing_is_none: bool = False) -> ResultT | None

Normalize a generated Data Hub response into document-layer exceptions.

Arguments:

  • result - Generated client payload or error model.
  • missing_is_none - When True, a 404 response returns None instead of raising NotFoundError.

Returns:

The successful payload, or None for tolerated missing resources.

Raises:

  • DocumentOperationError - When the payload represents a Data Hub failure.
  • NotFoundError - When the upstream service returned 404 and missing_is_none is False.

ensure_alerts_success​

def ensure_alerts_success(result: ResultT | AlertsError2
| AlertsValidationFailure | None,
*,
missing_is_none: bool = False) -> ResultT | None

Normalize a generated Alerts response into alert-layer exceptions.

Arguments:

  • result - Generated client payload or error model.
  • missing_is_none - When True, a 404 response returns None instead of raising NotFoundError.

Returns:

The successful payload, or None for tolerated missing resources.

Raises:

  • AlertOperationError - When the payload represents an Alerts failure.
  • AlertNotFoundError - When the failure is a 404 and missing_is_none is False. It is an AlertOperationError.

ensure_search_success​

def ensure_search_success(result: ResultT | SandError2 | None,
*,
missing_is_none: bool = False) -> ResultT | None

Normalize a generated SAND response into search-layer exceptions.

Arguments:

  • result - Generated client payload or error model.
  • missing_is_none - When True, a 404 response returns None instead of raising NotFoundError.

Returns:

The successful payload, or None for tolerated missing resources.

Raises:

  • SearchOperationError - When the payload represents a SAND failure.
  • InvalidSearchQueryError - When the SAND error is a 400 or 422. It is a SearchOperationError.

ensure_workflows_success​

def ensure_workflows_success(result: ResultT | WorkflowsError2 | None,
*,
missing_is_none: bool = False) -> ResultT | None

Normalize a generated Workflows response into workflow-layer exceptions.

Arguments:

  • result - Generated client payload or error model.
  • missing_is_none - When True, a 404 response returns None instead of raising NotFoundError.

Returns:

The successful payload, or None for tolerated missing resources.

Raises:

  • WorkflowOperationError - When the payload represents a workflow failure.
  • WorkflowNotFoundError - When the upstream service returned 404 and missing_is_none is False.