feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error (#19) #20

Merged
andreban merged 2 commits from feat/retry-delay into main 2026-10-28 08:48:51 +00:00
Owner

Closes #19

Changes

  • src/types/error.rs: VertexApiError.details is now Option<Vec<serde_json::Value>>. Previously a 429 RESOURCE_EXHAUSTED body containing a google.rpc.RetryInfo (or any other untyped google.rpc.* detail) failed to deserialize and the client fell back to Error::HttpStatus.
  • Added VertexApiError::retry_delay() -> Option<Duration>. It finds a detail whose @type is google.rpc.RetryInfo or ends with /google.rpc.RetryInfo, reads retryDelay (or retry_delay), and parses the protobuf duration ("37s", "1.5s").
  • src/error.rs: added Error::retry_delay(), which delegates for Error::VertexError and returns None for every other variant.

Breaking changes

  • VertexApiError.details changed type.
  • Removed the unused public types ErrorType, ErrorInfoMetadata, FieldViolation and Link.

Tests

Ported the unit tests from andreban/geologia@69e4108: whole and fractional delays, multiple details entries, malformed or missing delays, short and snake_case forms, and Error delegation. Added a deserialization test with an unknown detail type, plus a doctest. cargo test and cargo clippy --all-targets pass.

Closes #19 ## Changes - `src/types/error.rs`: `VertexApiError.details` is now `Option<Vec<serde_json::Value>>`. Previously a `429 RESOURCE_EXHAUSTED` body containing a `google.rpc.RetryInfo` (or any other untyped `google.rpc.*` detail) failed to deserialize and the client fell back to `Error::HttpStatus`. - Added `VertexApiError::retry_delay() -> Option<Duration>`. It finds a detail whose `@type` is `google.rpc.RetryInfo` or ends with `/google.rpc.RetryInfo`, reads `retryDelay` (or `retry_delay`), and parses the protobuf duration (`"37s"`, `"1.5s"`). - `src/error.rs`: added `Error::retry_delay()`, which delegates for `Error::VertexError` and returns `None` for every other variant. ## Breaking changes - `VertexApiError.details` changed type. - Removed the unused public types `ErrorType`, `ErrorInfoMetadata`, `FieldViolation` and `Link`. ## Tests Ported the unit tests from andreban/geologia@69e4108: whole and fractional delays, multiple details entries, malformed or missing delays, short and snake_case forms, and `Error` delegation. Added a deserialization test with an unknown detail type, plus a doctest. `cargo test` and `cargo clippy --all-targets` pass.
andreban added 1 commit 2026-10-28 08:38:25 +00:00
feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error (#19)
All checks were successful
Rust / check (pull_request) Successful in 2m40s
cecc14d31e
VertexApiError.details is now Option<Vec<serde_json::Value>> so that
unknown google.rpc.* detail types (e.g. RetryInfo, QuotaFailure) no
longer break deserialization and fall back to Error::HttpStatus. The
unused ErrorType, ErrorInfoMetadata, FieldViolation and Link types are
removed.

Add VertexApiError::retry_delay() which parses the protobuf duration in a
google.rpc.RetryInfo entry, and Error::retry_delay() which delegates to it.

Closes #19
andreban force-pushed feat/retry-delay from f7cc9977aa to cecc14d31e 2026-10-28 08:38:25 +00:00 Compare
andreban added 1 commit 2026-10-28 08:44:56 +00:00
refactor: address review feedback on retry_delay (#19)
All checks were successful
Rust / check (pull_request) Successful in 2m42s
a49d37f03d
- Drop the unreachable checked_mul in parse_duration; a fraction of at
  most 9 digits scaled to nanoseconds always fits in a u32.
- Share a vertex_error test helper in error.rs instead of building
  VertexApiError inline.
- Bump version to 0.2.0 for the breaking VertexApiError.details change.
andreban merged commit faa72a6d7a into main 2026-10-28 08:48:51 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: andreban/gemini-rs#20