Repository navigation
fix: Send one Idempotency-Key on every POST and its retries - #457
Merged
Merged
Conversation
The SDK retried POSTs on connection errors and 5xx responses but only sent an Idempotency-Key when the caller supplied one, so a retry after a lost response could create a duplicate, including on Pipes explicit adds, where the API deduplicates by key. Generate one key per POST before the first attempt and reuse it on every retry; a caller's key, through RequestOptions or an Idempotency-Key extra header, still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues remain. SummaryEvery
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dandorman
approved these changes
Oct 22, 2026
…n-post # Conflicts: # tests/HttpClientTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Every
POSTnow carries anIdempotency-Key, generated once before the first attempt and reused on every retry. Before, the SDK retriedPOSTs on connection errors and 429/5xx responses but only sent a key when the caller supplied one. If the first attempt created something but its response was lost, the retry looked like a brand-new request.That matters now that the API deduplicates by key on Pipes explicit adds (
createDataIntegrationApiKey,createDataIntegrationClientCredential, and thecreate*ConnectedAccountimports withconnectionIntent: 'add'), not just audit log events. A retried add could create a second connected account holding live credentials. Go, Python, and .NET already key the firstPOST.RequestOptions(idempotencyKey: ...)or as anIdempotency-Keyextra header (matched case-insensitively).PUT,PATCH,GET, andDELETEare unchanged.Proof:
testPostRetriesReuseOneGeneratedIdempotencyKeyfails onmain(both attempts go out with an emptyIdempotency-Key) and passes here (both attempts carry the same key).testPostKeepsCallerIdempotencyKeyFromExtraHeadersguards the new branch that keeps a caller's header key.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
No WorkOS Docs change needed; the README is updated here.
🤖 Generated with Claude Code