Description
Build a request deduplication middleware that uses client-supplied idempotency keys to prevent duplicate deployment creation when requests are retried due to network failures or client retries.
Requirements and Context
- Security: Idempotency keys must be scoped per user to prevent cross-tenant collisions
- Testing: Unit and integration tests for the middleware
- Documentation: Document the idempotency key header in the OpenAPI spec
Suggested Execution
Branch: feat/issue-051-deployment-idempotency-middleware
Implement Changes
- Add middleware that reads an
Idempotency-Key header on deployment creation routes
- Store processed keys with their responses in a short-lived cache keyed by user + key
- Return the cached response when a duplicate key is received within the window
- Apply the middleware to
apps/backend/src/app/api/deployments/route.ts
Test and Commit
- Test that duplicate requests with the same key return the original response
- Test that different keys create separate deployments
- Document the
Idempotency-Key header in apps/backend/openapi.yaml
Example Commit Message
feat(deployments): add request deduplication middleware for idempotent creation
- Add Idempotency-Key header handling middleware
- Cache responses per user+key within a time window
- Apply middleware to deployment creation route
Guidelines
- Scope idempotency keys per authenticated user
- Set a reasonable cache TTL (e.g., 24 hours)
- Open a PR against
main with tests and OpenAPI updates
Description
Build a request deduplication middleware that uses client-supplied idempotency keys to prevent duplicate deployment creation when requests are retried due to network failures or client retries.
Requirements and Context
Suggested Execution
Branch:
feat/issue-051-deployment-idempotency-middlewareImplement Changes
Idempotency-Keyheader on deployment creation routesapps/backend/src/app/api/deployments/route.tsTest and Commit
Idempotency-Keyheader inapps/backend/openapi.yamlExample Commit Message
Guidelines
mainwith tests and OpenAPI updates