Skip to content

fix: Send Idempotency-Key on the first POST attempt - #567

Open
thompsongl wants to merge 1 commit into
mainfrom
fix/idempotency-key-on-first-post
Open

thompsongl wants to merge 1 commit into
mainfrom
fix/idempotency-key-on-first-post

Conversation

@thompsongl

Copy link
Copy Markdown

Description

Every POST now carries an Idempotency-Key from the first attempt. Before, the SDK only generated one when scheduling a retry, so attempt 1 went out keyless. If that first attempt created something but its response was lost (a timeout, a reset connection), the retry carried a brand-new key and the API had no way to recognize it as the same request.

That matters now that the API deduplicates by key on Pipes explicit adds (create_data_integration_api_key, create_data_integration_client_credential, and the create_*_connected_account imports with connection_intent: "add"), not just audit_logs.create_event. With a keyless first attempt, a retried add could create a second connected account holding live credentials. Go, Python, and .NET already key the first POST.

  • A caller-supplied request_options[:idempotency_key] still wins.
  • PUT and PATCH are unchanged: keyed when you supply one, or on retry.
  • 409 stays retryable. That's a separate cleanup (409s are deterministic, so retrying them only adds latency), not part of this fix.

Proof: the updated test_post_sends_one_idempotency_key_on_the_first_attempt_and_its_retries fails on main (only the retry carries a key) and passes here (both attempts carry the same key).

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

The README's idempotency section is updated in this PR, including Pipes explicit adds among the endpoints that honor the key. No WorkOS Docs change needed.

🤖 Generated with Claude Code

The key was generated only when scheduling a retry, so attempt 1 went out
keyless. If that attempt created a resource but its response was lost, the
retry carried a fresh key and could create a duplicate, including on Pipes
explicit adds, where the API deduplicates by key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thompsongl
thompsongl requested review from a team as code owners October 19, 2026 18:32
@thompsongl
thompsongl requested a review from tribble October 19, 2026 18:32
@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

POST requests now receive an Idempotency-Key before their first attempt and keep it across retries.

  • Every POST carries the same idempotency key from its first send through retries.

Diagram

sequenceDiagram
    participant App
    participant SDK
    participant API
    App->>SDK: POST
    SDK->>SDK: Keep supplied key or generate one
    SDK->>API: First attempt with key
    API-->>SDK: Retryable response or connection failure
    SDK->>API: Retry with the same key
Loading

Reviews (1) · Last reviewed commit: "fix: Send Idempotency-Key on the first P..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

1 participant