Skip to content

Implement request idempotency key middleware in @astroid/client #96

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Autonomous agents performing financial transactions and state mutations via the SDK need protection against duplicate submissions caused by network retries or client crashes. This issue adds automatic idempotency key generation and header injection for mutating HTTP methods (POST, PUT, PATCH, DELETE) in @astroid/client.

Context & Requirements — background, constraints, design references, edge cases; grounded in the actual repo (real files, stack, conventions).

Mutating requests should automatically include an Idempotency-Key header using UUID v4 generation if one is not explicitly provided by the caller. The client should also allow callers to override or supply custom idempotency keys via request options.

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Automatically attach an Idempotency-Key header to POST, PUT, PATCH, and DELETE requests.
  • Allow callers to pass a custom idempotency key via request configuration options.
  • Ensure idempotent keys are not attached to GET or HEAD requests.
  • Add unit tests verifying header presence and custom override behavior.

Implementation Guidance — likely files/modules to touch (use real paths from the repo context) and a suggested approach, without over-prescribing.

Examine packages/client/src/ to locate request building logic. Integrate standard crypto.randomUUID() or a lightweight generator compliant with Node 20+ runtime requirements.

Testing & Validation — how the contributor should prove it works (tests to add/run, manual checks, screenshots for UI).

Run pnpm test --filter @astroid/client and verify test coverage for request headers.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting; follow the repo's existing style and conventions.


Wave complexity: Medium

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions