Skip to content

Implement Request Deduplication Middleware for Idempotent Deployment Creation Endpoints #587

@temma02

Description

@temma02

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions