Skip to content

Canonicalize request bodies before computing idempotency digests#1606

Merged
kryputh merged 1 commit into
Stellar-Mail:mainfrom
Esc1200:fix/1501-idempotency-canonicalization
Jul 20, 2026
Merged

Canonicalize request bodies before computing idempotency digests#1606
kryputh merged 1 commit into
Stellar-Mail:mainfrom
Esc1200:fix/1501-idempotency-canonicalization

Conversation

@Esc1200

@Esc1200 Esc1200 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Goal

Enforce canonical JSON serialization for idempotency digests (issue #1501) so semantically identical requests hash the same while genuinely different values still conflict.

Changes

  • src/server/api/idempotency-service.ts: hashIdempotencyKey now canonicalizes the raw key via the existing JCS canonicalize() helper before hashing, so object-key ordering no longer changes the digest.
  • tests/unit/api/idempotency-canonicalization.test.ts: key-order invariance, array-order significance, numeric-vs-string distinction, nested-structure sensitivity, actor binding, and determinism.

Verification

  • npx vitest run tests/unit/api/idempotency-canonicalization.test.ts → 6 passed.
  • npx prettier@3.8.5 --check clean on changed files.

Fixes #1501

@kryputh
kryputh merged commit 16c3d78 into Stellar-Mail:main Jul 20, 2026
5 checks passed
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.

Canonicalize request bodies before computing idempotency digests

2 participants