Repository navigation
feat(idempotency): add idempotency-key support to mutating commands - #38
Merged
Merged
Conversation
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.
What / why
Upstream spec 1.1.1 adds an optional
Idempotency-Keyheader (components.parameters.idempotencyKey) to 41 POST operations. This PR lets you retry the POSTs where a retry matters most after a timeout or lost response, without running the request twice.Changes
internal/n8n)idempotency.go: theIdempotencyKey(key)call option, a key check matching the spec (1–128 visible ASCII characters), a UUIDv4 generator, and theIsIdempotencyInProgress(409) /IsIdempotencyMismatch(422) helpers.Request.IdempotencyKeyfield:Dochecks the key before sending and sets the header only when a key is given.opts ...CallOption, so existing callers don't change.APIErrorinstead of anImportBlockedError.--idempotency-key KEY|autoon 14 commands:execution stop,stop-many,retryworkflow createdata-table row insert,upsertpromotion promote,apply,apply-continuepromotion project apply,apply-continue,promotepackage import,import-selectionautogenerates a UUID and prints it on stderr with the retry command. Stdout stays machine-readable.auto.Idempotency-Key. The same status codes also mean real resource conflicts here (import blocked, execution not stoppable or retryable), and those keep their usual diagnostics.docs/regenerated.Verification
make checkpasses locally: formatting, vet, staticcheck, unit tests, race tests, all five cross-builds, tidy check, and vulnerability scan (No vulnerabilities found.).go test -shuffle=on -count=1 ./internal/n8n ./internal/clipasses.make docsrun;TestDocsAreCurrentpasses.openapi.upstream.ymlpresent,go test ./internal/coverage/passes. No manifest change: a header option, not a new operation.v*tag or release commit in this PR.Tests cover, at both the client and CLI layers:
autoprints the key on stderr only and makes a new key on each runNotes for reviewer
packages/cli/src/idempotency/idempotency.middleware.ts), and the fact that retries are matched on method + path + query + raw body (ADR-20261005-replay-the-first-public-api-response-for-an-idempotency-key). No live instance was used.validate/resolve/refusal.🤖 Generated with Claude Code