Exceptions¶
All exceptions raised by the Pinecone SDK derive from PineconeError
so that a single except PineconeError block can catch every SDK error if desired.
Class Hierarchy¶
PineconeError
├── PineconeValueError (also ValueError)
├── PineconeTypeError (also TypeError)
├── PineconeConnectionError
├── PineconeTimeoutError (also TimeoutError)
├── ResponseParsingError
├── IndexInitFailedError
├── IndexTerminatedError
└── ApiError
├── ConflictError (409)
├── NotFoundError (404)
├── ForbiddenError (403)
├── UnauthorizedError (401)
├── PaymentRequiredError (402)
├── FailedPreconditionError (412)
├── RateLimitError (429)
└── ServiceError (5xx)
Base & Configuration Errors¶
- exception pinecone.errors.exceptions.PineconeError(message)[source]¶
Bases:
ExceptionBase class for every exception the SDK raises.
Catch this when one handler should cover any SDK failure; catch a subclass when a particular failure needs its own recovery.
messageholds the text the SDK or the server produced.Three subclasses also derive from a builtin —
PineconeValueErrorfromValueError,PineconeTypeErrorfromTypeError,PineconeTimeoutErrorfromTimeoutError— so anexcept ValueErroralready in your code catches those without importing anything from Pinecone.Examples
>>> from pinecone import NotFoundError, PineconeError >>> try: ... raise NotFoundError(message="No index named 'movie-recommendations'") ... except PineconeError as exc: ... print(type(exc).__name__, exc.message) NotFoundError No index named 'movie-recommendations'
See also
Error Handling — which errors a given call produces, what the SDK retries before raising, and how to order handlers.
- Parameters:
message (str)
- Return type:
None
- exception pinecone.errors.exceptions.PineconeValueError(message, path=None)[source]¶
Bases:
PineconeError,ValueErrorAn argument had the right type but an unusable value.
The SDK’s own validation raises this before the request goes out, so nothing was created or changed. Fix the argument the message names.
pathlocates the offending field when the raiser supplied one, andstr(exc)then prefixes the message withat <path>:. Also derives fromValueError, so anexcept ValueErroralready in your code catches it.Examples
>>> from pinecone import PineconeValueError >>> print(PineconeValueError("dimension must be positive", "fields.embedding")) at fields.embedding: dimension must be positive
- exception pinecone.errors.exceptions.PineconeTypeError(message, path=None)[source]¶
Bases:
PineconeError,TypeErrorAn argument was of a type the SDK cannot use.
Raised before the request goes out, so nothing was created or changed. Passing a keyword this SDK version no longer accepts produces this too, with a message naming the current argument to use instead.
When the failure is a value inside a request body that will not JSON-encode,
pathlocates it —records[2].embedding— which is the part worth reading on a bulk call.str(exc)prefixes the message withat <path>:. Also derives fromTypeError.
- exception pinecone.errors.exceptions.ResponseParsingError(message, cause=None)[source]¶
Bases:
PineconeErrorThe response arrived but the SDK could not decode it.
The request succeeded, so this is not a failure you can fix by changing it. The usual cause is a response carrying a shape this SDK version does not model — a new deployment type or read-capacity mode, for instance — which an SDK upgrade resolves.
causeholds the underlying deserialization error, andstr(exc)appends it, so the message already names the field that would not decode. Wrapping it this way is what lets anexcept PineconeErrorblock catch a decode failure at all.
- exception pinecone.errors.exceptions.IndexInitFailedError(index_name)[source]¶
Bases:
PineconeErrorAn index entered
InitializationFailedwhile the SDK waited for it.Only a call that polls for readiness raises this —
create()andcreate_for_model()do so unless you passtimeout=-1to return immediately. The index exists but will never become ready: delete it and create again, changing the deployment if that is what failed.index_nameis the index that failed.- Parameters:
index_name (str)
- Return type:
None
- exception pinecone.errors.exceptions.IndexTerminatedError(name, state)[source]¶
Bases:
PineconeErrorAn index reached a terminal state while the SDK waited for it.
The terminal states are
TerminatingandDisabled. Something outside this call deleted or disabled the index mid-wait, so waiting longer cannot succeed.nameandstatesay which index and which state;describe()confirms whether it still exists.
Network Errors¶
- exception pinecone.errors.exceptions.PineconeConnectionError(message)[source]¶
Bases:
PineconeErrorThe connection failed before any response arrived.
Covers DNS resolution failures, connection refused, read/write errors, and other transport-level problems. The SDK retries transport failures, so one reaching your code means the retry budget was spent — look at DNS, egress rules, and any proxy between you and Pinecone rather than at the request.
- Parameters:
message (str)
- Return type:
None
- exception pinecone.errors.exceptions.PineconeTimeoutError(message, *, response=None)[source]¶
Bases:
PineconeError,TimeoutErrorAn operation exceeded its timeout.
Two deadlines produce this: a single HTTP request that outran the client’s request timeout, and a readiness wait — creating or deleting an index, say — that outran the
timeoutyou passed. The first is worth retrying; the second usually means the resource is still working, so describe it rather than re-issuing the call.Multiply inherits from Python’s built-in
TimeoutErrorso thatexcept TimeoutErrorblocks in caller code catch SDK timeouts without having to import a Pinecone-specific class. This is the same pattern used byPineconeValueError(extendsValueError).- Parameters:
message (str) – Description of what timed out.
response (Any | None) – Partial result, when the timeout interrupted a bulk operation that had already applied some of its work. Carrying it means the caller can tell what landed instead of having to re-send everything;
response.failed_itemsis what remains.Nonefor timeouts with nothing partial to report.
- Return type:
None
API Errors¶
- exception pinecone.errors.exceptions.ApiError(message, status_code, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
PineconeErrorThe server answered with an HTTP error status.
Every status-specific class below derives from this one, so
except ApiErrorcatches all of them. A status with no dedicated subclass reaches the caller as a bareApiError—400and422, which are what a request the server considers malformed produces.Two attributes are worth reading.
status_codesays which class of failure it was;bodyis the parsed JSON response, and it is where a field-level explanation lives when the server sent one.str(exc)already renders the status, the server’s error code, and the request id, so logging the exception loses nothing. Quoterequest_idwhen you open a support ticket.Examples
>>> from pinecone import ApiError >>> exc = ApiError( ... "No index named 'movie-recommendations'", ... 404, ... body={"error": {"code": "NOT_FOUND"}}, ... request_id="req-9f2c", ... ) >>> print(exc) [404] No index named 'movie-recommendations' (request_id: req-9f2c) >>> exc.status_code, exc.body["error"]["code"] (404, 'NOT_FOUND')
See also
Error Handling — the full attribute table, and the handler shape for each status.
- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.NotFoundError(message='Resource not found', status_code=404, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError404 — the resource the request named does not exist.
A misspelled name, a resource someone else already deleted, or an API key scoped to a different project than the one that owns the resource all produce this. When you only want to know whether an index is there,
exists()is clearer than catching this.Note
A
404is not proof of absence everywhere.describe()answers404for any failure to read the restore-job store, so there it means “could not produce this job”, not “no such job” — do not key control flow on it.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.ConflictError(message='Resource conflict', status_code=409, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError409 — the request conflicts with the resource’s current state.
Creating an index, collection, or backup under a name that is already taken is the common case. Guard the create with
exists(), or catch this and treat it as a no-op when concurrent callers make the check pointless.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.UnauthorizedError(message='Invalid or missing API key', status_code=401, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError401 — the request carried no usable credential.
The API key was missing, malformed, or has been deleted, or an
Adminclient’s OAuth2 credentials were rejected. Nothing about the request itself will fix it and retrying will not help: supply a valid credential. CheckPINECONE_API_KEYfirst when you did not passapi_keyexplicitly.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.ForbiddenError(message='Forbidden', status_code=403, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError403 — the credential is valid but the operation is not permitted.
Three causes account for most of these: the key’s roles do not cover the operation, a quota on the project or organization has been reached, or a protection setting on the resource forbids it — deletion protection makes
delete()answer403until you turn it off withconfigure().Retrying never helps.
messagecarries the server’s explanation, which is what distinguishes the three.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.PaymentRequiredError(message='Payment required', status_code=402, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError402 — the organization’s billing state blocks the operation.
Raised where the control plane gates resource creation on payment, notably
create()andcreate(), which need the organization to have an active payment method or a plan that permits the request.Retrying will not help: you or an organization owner has to resolve the billing state first.
messagecarries the server’s explanation verbatim, so it is the authoritative description of what needs fixing.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.FailedPreconditionError(message='Precondition failed', status_code=412, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError412 — the target resource is not in a state that permits the request.
The request was well-formed. This is the dominant admin failure class: deleting a project or organization that still owns resources, or deleting a backup with a restore job still in flight, all answer 412.
The precondition is usually satisfiable — delete the blocking resources, or wait for the in-flight operation to finish, then retry.
messagecarries the server’s explanation verbatim and typically names the specific resources or job ids that are in the way.- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.RateLimitError(message='Rate limit exceeded', status_code=429, body=None, *, reason=None, headers=None, error_code=None, request_id=None, retry_after=None)[source]¶
Bases:
ApiError429 — the request was throttled.
The SDK retries
429on its own, so one reaching your code means the retry budget was already spent. Retrying immediately in a loop will not get through; reduce the request rate, or raise the retry allowance.retry_afteris how long the server asked you to wait, in seconds. It is parsed from theRetry-Afterresponse header when that header is present and expressible as a non-negative number of seconds; an HTTP-date value is not parsed, and leavesretry_afterasNone.See also
Retries and Resilience — what the SDK retries by default and how to change it.
- Parameters:
- Return type:
None
- exception pinecone.errors.exceptions.ServiceError(message='Internal server error', status_code=500, body=None, *, reason=None, headers=None, error_code=None, request_id=None)[source]¶
Bases:
ApiError5xx — the server failed to handle a well-formed request.
Nothing about the request needs changing. The SDK already retries the common 5xx statuses, so one reaching your code means the retry budget was spent — back off further before trying again. A 5xx outside the retryable set arrives on the first attempt instead.
Read
status_codeto tell the two apart, and quoterequest_idif the failure persists.See also
Retries and Resilience — which statuses are retried by default.
- Parameters:
- Return type:
None
Deprecated Aliases¶
The following names are kept for backwards compatibility and will be removed in a future major release. New code should use the canonical names listed above.
Alias |
Canonical class |
Notes |
|---|---|---|
|
Legacy base-class name |
|
|
Legacy API error name |
|
|
Legacy configuration error |
|
|
Legacy protocol error |
|
|
Legacy type error |
|
|
Legacy value error |
|
|
Legacy attribute error |
|
|
Legacy key error |
|
|
Legacy 404 error |
|
|
Legacy 401 error |
|
|
Legacy 403 error |
|
|
Legacy 5xx error |
|
|
Legacy 429 error |
|
|
Legacy list conversion error |
|
|
Legacy validation alias |