mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
fix(python): surface typed remote resource errors (#4789)
## Summary - Parse structured `error_code` and `resource` fields from remote HTTP error bodies and carry them through Rust/PyO3. - Add `SecretNotFoundError`, `FunctionNotFoundError`, `NamespaceNotFoundError`, and `AlreadyExistsError` as `HttpError` subclasses. - Expose `error_code`, `resource_kind`, `resource_name`, and `namespace_path` on HTTP exceptions while preserving `status_code`, `request_id`, and existing `except HttpError` handlers. - Do not retry structured domain errors that would otherwise become `RetryError` (notably `already_exists` on 409). Older servers that do not provide the structured fields continue to raise a plain `HttpError`. ## Compatibility This consumes the stable resource error contract added in lancedb/sophon#9516 (merge commit `35858561b3`). The existing `TableNotFoundError` behavior is unchanged. Part of ENT-3373.
This commit is contained in:
@@ -748,10 +748,45 @@ so the fetch APIs cannot read their bytes yet.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Remote HTTP responses with structured resource details raise a subclass of
|
||||
`HttpError`. Older servers that omit those details raise plain `HttpError`, so
|
||||
`except HttpError` remains a compatible catch-all:
|
||||
|
||||
```python
|
||||
from lancedb.remote.errors import (
|
||||
AlreadyExistsError,
|
||||
FunctionNotFoundError,
|
||||
HttpError,
|
||||
NamespaceNotFoundError,
|
||||
SecretNotFoundError,
|
||||
)
|
||||
|
||||
try:
|
||||
db.describe_namespace(["analytics"])
|
||||
except (SecretNotFoundError, FunctionNotFoundError, NamespaceNotFoundError) as error:
|
||||
print(error.error_code, error.resource_kind, error.resource_name)
|
||||
except AlreadyExistsError as error:
|
||||
print("resource already exists:", error.resource_name)
|
||||
except HttpError as error:
|
||||
print("request failed:", error.request_id, error.status_code)
|
||||
```
|
||||
|
||||
Secret and function lifecycle APIs currently use Flight SQL and may still raise
|
||||
`RuntimeError`. The typed subclasses cover HTTP failures, including dependency
|
||||
errors during column refresh.
|
||||
|
||||
::: lancedb.remote.errors.HttpError
|
||||
|
||||
::: lancedb.remote.errors.TableNotFoundError
|
||||
|
||||
::: lancedb.remote.errors.SecretNotFoundError
|
||||
|
||||
::: lancedb.remote.errors.FunctionNotFoundError
|
||||
|
||||
::: lancedb.remote.errors.NamespaceNotFoundError
|
||||
|
||||
::: lancedb.remote.errors.AlreadyExistsError
|
||||
|
||||
::: lancedb.exceptions.MissingValueError
|
||||
|
||||
::: lancedb.exceptions.MissingColumnError
|
||||
|
||||
Reference in New Issue
Block a user