Skip to content

Idempotency keys on write requests - #286

Draft
schaloner wants to merge 1 commit into
masterfrom
steve/seats-1732-idempotent-requests-seatsio-java
Draft

schaloner wants to merge 1 commit into
masterfrom
steve/seats-1732-idempotent-requests-seatsio-java

Conversation

@schaloner

Copy link
Copy Markdown
Contributor

Send an Idempotency-Key (v4 UUID) with every POST/PUT/DELETE so a request whose outcome is unknown can be retried safely.

  • SeatsioException exposes idempotencyKey and outcomeIsUnknown() (connection failure, 5xx, or key still in use after retries)
  • SeatsioClient.withIdempotencyKey(key) returns a client that reuses a key; rejects non-v4-UUID keys
  • Retry 409 IDEMPOTENCY_KEY_IN_USE with backoff, like 429
  • retryNonIdempotentRequests(true) opts in to retrying POST/PUT/DELETE on connection errors with the same key (off by default)
  • Stop retrying when the thread is interrupted
  • Error bodies without an error code no longer break parsing: errors and requestId are null, message contains status and body (ErrorResponse)
  • README: document idempotency, retries and the new exception fields

Send an Idempotency-Key (v4 UUID) with every POST/PUT/DELETE so a request
whose outcome is unknown can be retried safely.

- SeatsioException exposes idempotencyKey and outcomeIsUnknown() (connection
  failure, 5xx, or key still in use after retries)
- SeatsioClient.withIdempotencyKey(key) returns a client that reuses a key;
  rejects non-v4-UUID keys
- Retry 409 IDEMPOTENCY_KEY_IN_USE with backoff, like 429
- retryNonIdempotentRequests(true) opts in to retrying POST/PUT/DELETE on
  connection errors with the same key (off by default)
- Stop retrying when the thread is interrupted
- Error bodies without an error code no longer break parsing: errors and
  requestId are null, message contains status and body (ErrorResponse)
- README: document idempotency, retries and the new exception fields
Copilot AI balanced review requested due to automatic review settings November 19, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review reports no active issues with the Java client’s idempotency and retry changes.

No open issues 🎉

What changed in this PR

Adds idempotency support to the Java client so callers can safely retry write requests with unknown outcomes when idempotency is enabled for their company.

Changes:

  • Adds generated UUID keys to write requests and client copies that reuse a supplied key.
  • Adds retries for keys still in use, opt-in connection-failure retries, and interruption handling.
  • Exposes retry-related exception details, improves error-response handling, and adds tests and documentation.
File Description
src/​test/​java/​seatsio/​SeatsioClientTest.java Adds setup for companies with idempotency enabled.
src/​test/​java/​seatsio/​IdempotentRetryTest.java Tests retry policies, key reuse, interruption, and unknown outcomes.
src/​test/​java/​seatsio/​IdempotencyKeyTest.java Tests key generation, validation, headers, and exception exposure.
src/​test/​java/​seatsio/​FakeServer.java Adds a local server for scripted responses and connection failures.
src/​test/​java/​seatsio/​events/​IdempotencyTest.java Adds integration tests for response replay and lost-response recovery.
src/​test/​java/​seatsio/​ErrorResponseTest.java Tests fallback handling for unstructured error responses.
src/​main/​java/​seatsio/​util/​UnirestWrapper.java Implements key attachment, shared retry settings, and retry control.
src/​main/​java/​seatsio/​util/​ErrorResponse.java Centralizes structured error-response parsing.
src/​main/​java/​seatsio/​SeatsioException.java Exposes idempotency keys and unknown outcomes; updates error construction.
src/​main/​java/​seatsio/​SeatsioClient.java Adds APIs for key reuse and opt-in write retries.
src/​main/​java/​seatsio/​exceptions/​RateLimitExceededException.java Adds a message-only constructor for fallback errors.
README.md Documents idempotency, retry settings, and exception fields.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants