Skip to content

Errors and retries

Errors

Every exception the SDK raises derives from volumes.VolumesError, so except volumes.VolumesError catches anything that can go wrong in a call: bad arguments, network failures, error responses, and responses that cannot be understood.

That holds without exception for a client that uses the SDK's own HTTP client (the default). If you pass your own http_client, there is one more source of exceptions, which the SDK does not rename: anything raised by code you put into that client (a custom transport, an event hook, an auth flow) that is not one of httpx's own request errors reaches you unchanged, for example a RuntimeError raised by your transport. See Custom transport.

VolumesError
├── ConfigurationError            the client was created with unusable settings
├── InvalidArgumentError          a method was called with an unusable argument
├── ClientClosedError             the client was used after close()
├── APIConnectionError            no response: DNS, refused connection, reset, ...
│   └── APITimeoutError           no response in time
├── InvalidResponseError          a success response that could not be understood
└── APIError                      the API answered with an error status
    ├── BadRequestError               400
    ├── AuthenticationError           401
    ├── NotFoundError                 404
    │   ├── CaptureNotFoundError          no such capture for this key
    │   └── MetadataNotAvailableError     capture is accessible; file not there yet
    ├── RateLimitError                429  (.retry_after)
    └── ServerError                   5xx

Invalid arguments. The SDK never raises a bare ValueError or TypeError for something you passed in. A bad argument to volumes.Client(...) raises ConfigurationError; a bad argument to a method raises InvalidArgumentError, for a wrong type and a wrong value alike. Both are VolumesErrors that also subclass ValueError, so existing except ValueError handlers keep working. Both are raised before any request is sent.

Argument Must be
capture_id a non-empty string of at most 1024 characters
page_size an integer from 1 to 1000 (or omitted)

A wrong setting passed to volumes.Client(...) is reported the same way, as a ConfigurationError: max_retries outside 0 to 10, an unusable timeout, a base_url that is not https:// (or loopback http://), that contains ? or #, or that is otherwise not a usable URL.

Whatever characters a capture_id contains, it is percent-encoded into a single URL path segment, so it can never address a different endpoint.

Error responses. APIError and its subclasses carry what the API reported:

Attribute Meaning
status_code HTTP status
code Stable machine-readable code, such as "capture_not_found". None if the response was not in the API's error format (for example an HTML page from a proxy).
message Human-readable description
request_id Identifier of the request. Include it when you contact support. If what the server sent as the id contains your API key (in any letter case) or anything shaped like an API key, it is replaced by "[redacted]".
import volumes

client = volumes.Client()

try:
    frame_sync = client.get_frame_sync("capture_demo_001")
except volumes.CaptureNotFoundError:
    # The capture does not exist, or this key has no access to it.
    # The API does not say which.
    ...
except volumes.MetadataNotAvailableError:
    # The capture is yours, but its frame sync has not been produced yet. Try later.
    ...
except volumes.AuthenticationError:
    # The key is wrong, revoked, or the account is disabled.
    ...
except volumes.RateLimitError as error:
    print("slow down; retry after", error.retry_after, "seconds")
except volumes.APIConnectionError:
    # Network problem or timeout (APITimeoutError is a subclass).
    ...
except volumes.APIError as error:
    print(error.status_code, error.code, error.message, error.request_id)
Status code Exception
400 invalid_request BadRequestError
401 invalid_api_key AuthenticationError
404 capture_not_found CaptureNotFoundError
404 frame_sync_not_available, scene_summary_not_available MetadataNotAvailableError
404 anything else NotFoundError
429 any RateLimitError
5xx internal_error, service_unavailable, or none ServerError
other any APIError

Responses that cannot be understood raise InvalidResponseError:

  • a success response that is not of the type the endpoint returns: Content-Type: text/csv for frame sync and application/json for everything else (a charset or other parameter is ignored). A 200 with another type, such as the HTML sign-in page of a proxy, is never returned as data;
  • a JSON body that is not JSON or has the wrong shape;
  • frame sync bytes that are not UTF-8 (raised when .text or .rows is read) or text that cannot be parsed as CSV (raised when .rows is read);
  • pagination that would never end (the same cursor twice, or more than five empty pages in a row that each promise more), or a cursor that contains your API key: a cursor is sent back in the next request's URL, and the key never goes into a URL.

The exception never carries the response body, not even indirectly through a chained exception: the body may be large, and it is data, not a diagnostic. For frame sync it is available as .content.

It carries status_code and request_id like the error responses above.

Retries

Requests that fail for transient reasons are retried automatically, up to max_retries times (default 2, so at most 3 attempts; the most that can be configured is 10):

Retried Never retried
connection errors 400
timeouts 401
429 404 (including "not available yet")
any 5xx every other 4xx

Between attempts the client waits with exponential backoff and jitter: about 0.5 s, 1 s, 2 s, ... capped at 8 s, each reduced randomly by up to half.

If the response has a Retry-After header (seconds or an HTTP date), the client waits at least that long, plus a random extra of up to one backoff step (0.5 s on the first retry, 1 s on the second, ...), capped at 60 s in total. The extra is deliberate: a busy server tells every client the same number at the same moment, and without it they would all return together.

When the retries are used up, the last error is raised. Each page fetched by list_captures() / iter_captures() has its own retry budget.

volumes.Client(max_retries=0)  # fail fast
volumes.Client(max_retries=5)  # more patient