Repository navigation
fix(api): honour the idempotency key when an administrator creates a privacy case - #1017
Merged
Medformatik merged 1 commit intoNov 16, 2026
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 changed and why
Creating a privacy case as an administrator requires an
Idempotency-Key, but the key did nothing for a create. Replay protection looked for an earlier event with the same key on the same case, and every create makes a new case. The only duplicate guard was "one active request per account and kind", which does not apply to a subject without an account.So a retried
POSTfor a subject identified by e-mail or post created a second case, with its own statutory deadline, administrator alerts and tasks. The bundled admin page uses a fresh key per click and disables its button, so this mainly affects API clients and automatic retries after a lost response.A create that carries a key now first looks for an earlier create with the same key by the same administrator, inside the lock every create already takes, so two concurrent creates run one after the other:
409 IDEMPOTENCY_KEY_REUSED, as the other privacy mutations answer."Same request" is judged by a digest stored on the case's first event, covering kind, channel, account, locator type, supplied receipt time, locale and time zone. The subject's e-mail or postal locator is left out on purpose: it is stored encrypted, and an unsalted digest of an address could be confirmed by guessing. A key reused for a different subject therefore returns the original case.
No schema or route schema changes. A retry that straddles the update gets
409, not a duplicate.Verification
admin-workflows-postgres.test.ts, run against a disposable PostgreSQL: a replay for an account-less subject returns one case, two concurrent creates with one key produce one case, a different key creates a second case, and the same key with a different channel gets409. Three failed before the change; with the lookup disabled they fail again.lifecycle-postgres.test.ts, the API typecheck and Biome on the touched files pass locally.Release and upgrade impact
Product impact: ordinary