Skip to content

feat: Idempotency-Key for POST /emails/send - #96

Open
patoperpetua wants to merge 1 commit into
mainfrom
feat/37-send-idempotency
Open

feat: Idempotency-Key for POST /emails/send#96
patoperpetua wants to merge 1 commit into
mainfrom
feat/37-send-idempotency

Conversation

@patoperpetua

Copy link
Copy Markdown
Contributor

Summary

  • Optional Idempotency-Key on POST /emails/send: absent keeps at-least-once behaviour; present claims a per-tenant Blob ledger before the provider call
  • Completed replays return the original SendResponse without a second provider call; in-flight replays return 409 IDEMPOTENCY_IN_PROGRESS
  • Persistence: Azure Blob (existing @azure/storage-blob) rather than Table — no new dependency; decision and 24h TTL documented in docs/architecture/send-idempotency.md

Closes #37

Test plan

  • pnpm --filter @singleton-sd/post-kit-types test
  • pnpm --filter @singleton-sd/post-kit-api test (replay, concurrent in-flight, cross-tenant, no-header, key validation, blob store fakes)
  • CI Lint / test / build green
  • Human: confirm idempotency container exists (or will be created) on the template storage account before prod use

Made with Cursor

Prevent double-sends on client retries by claiming a per-tenant Blob ledger
entry before the provider call, replaying completed responses, and returning
IDEMPOTENCY_IN_PROGRESS while a claim is in flight.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 1a7ae4c7-db23-4283-b59c-6e313c2a64a6

📥 Commits

Reviewing files that changed from the base of the PR and between e40f3e1 and 8d09d23.

📒 Files selected for processing (19)
  • .env.example
  • apps/api/src/config/app-configuration.ts
  • apps/api/src/functions/send.idempotency.spec.ts
  • apps/api/src/functions/send.ts
  • apps/api/src/idempotency/blob-idempotency-store.spec.ts
  • apps/api/src/idempotency/blob-idempotency-store.ts
  • apps/api/src/idempotency/idempotency-key.spec.ts
  • apps/api/src/idempotency/idempotency-key.ts
  • apps/api/src/idempotency/idempotency-store.ts
  • apps/api/src/idempotency/index.ts
  • apps/api/src/idempotency/memory-idempotency-store.spec.ts
  • apps/api/src/idempotency/memory-idempotency-store.ts
  • docs/architecture/overview.md
  • docs/architecture/request-lifecycle.md
  • docs/architecture/send-idempotency.md
  • docs/operations/troubleshooting.md
  • packages/post-kit-types/README.md
  • packages/post-kit-types/src/index.spec.ts
  • packages/post-kit-types/src/send.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@patoperpetua

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 40 minutes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define and implement an idempotency model for POST /emails/send

1 participant