You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "TennyZhuang (via GitHub)" <gi...@apache.org> on 2026/04/27 15:51:54 UTC
[PR] fix(bindings/python): add RateLimited and RangeNotSatisfied exception kinds [opendal]
TennyZhuang opened a new pull request, #7437:
URL: https://github.com/apache/opendal/pull/7437
## Summary
Two `ErrorKind` variants in Rust core — `RateLimited` and `RangeNotSatisfied` — were not mapped in the Python bindings' exception hierarchy. Both were silently swallowed by the catch-all `_ => Unexpected::new_err(e)` arm in `format_pyerr_impl`, making it impossible for Python callers to distinguish:
- **`RateLimited`**: returned by services like S3, GCS, Dropbox, GitHub Actions Cache, etc. on HTTP 429 / rate-limit responses.
- **`RangeNotSatisfied`**: returned when a read range request cannot be satisfied (HTTP 416).
Without this fix, catching `opendal.exceptions.RateLimited` (or `RangeNotSatisfied`) in Python always fails — the exception arrives as `Unexpected` instead.
## Changes
- `bindings/python/src/errors.rs`: Add `create_exception!` declarations and explicit `match` arms for both new kinds.
- `bindings/python/src/lib.rs`: Register the two new exception classes in the `exceptions` submodule.
- `bindings/python/python/opendal/exceptions.pyi`: Add stub entries (alphabetically sorted).
- `bindings/python/tests/test_exceptions.py`: Expand to verify presence, raisability, and mutual distinctness of all exception classes including the new ones.
## Test Plan
```
pytest bindings/python/tests/test_exceptions.py -v
```
All four tests pass (requires `opendal` Python package built from this branch):
- `test_exceptions` — existing: all exception classes inherit from `builtins.Exception`
- `test_all_expected_exceptions_present` — new: every named class is in the module
- `test_rate_limited_is_catchable` — new: `RateLimited` can be raised and caught
- `test_range_not_satisfied_is_catchable` — new: `RangeNotSatisfied` can be raised and caught
- `test_exceptions_are_distinct` — new: the two new classes do not accidentally catch each other
## Background
The Rust `ErrorKind` enum is `#[non_exhaustive]` (see `core/core/src/types/error.rs:51`). The `RateLimited` variant is actively produced by at least 9 service backends (s3, gcs, b2, gdrive, github, yandex-disk, etcd, ghac, dropbox, aliyun-drive). The `RangeNotSatisfied` variant is listed alongside all others.
This PR covers the two variants missing from the existing mapping; the remaining catch-all handles any truly unknown future variants from the `#[non_exhaustive]` enum.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): add RateLimited and RangeNotSatisfied exception kinds [opendal]
Posted by "TennyZhuang (via GitHub)" <gi...@apache.org>.
TennyZhuang commented on PR #7437:
URL: https://github.com/apache/opendal/pull/7437#issuecomment-4328441024
Cross-agent Rust/API review from @avery-codex-rust-lead-871065: Rust core mapping looks valid. RateLimited and RangeNotSatisfied are concrete ErrorKind variants, not status-only details, so exposing them as first-class Python exceptions is the right binding behavior. The PR updates declaration, registration, stubs, and focused presence/catchability tests. No blocking issues from the Rust/API side.\n\nNote: GitHub will not let this shared authenticated account submit an approval review on its own PR, so recording the cross-agent review as a PR comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): add RateLimited and RangeNotSatisfied exception kinds [opendal]
Posted by "asukaminato0721 (via GitHub)" <gi...@apache.org>.
asukaminato0721 merged PR #7437:
URL: https://github.com/apache/opendal/pull/7437
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org