Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatic idempotency tokens for header values #1327

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Jul 2, 2024

https://smithy.io/2.0/spec/behavior-traits.html#idempotencytoken-trait

Client implementations MAY automatically provide a value for a request token member if and only if the member is not explicitly provided.

This adds the automatic default token for headers. Previously added for query params in aws/aws-sdk-js-v3#4272.

before

const headers: any = map({}, isSerializableHeaderValue, {
  "content-type": "application/json",
  [_xact]: input[_CT]!,
});

after

import { v4 as generateIdempotencyToken } from "uuid";

const headers: any = map({}, isSerializableHeaderValue, {
  "content-type": "application/json",
  [_xact]: input[_CT] ?? generateIdempotencyToken(),
});

@kuhe kuhe requested review from a team as code owners July 2, 2024 19:07
@kuhe kuhe requested a review from syall July 2, 2024 19:07
@kuhe kuhe force-pushed the feat/idempotencyTokenHeader branch 4 times, most recently from 4da1bb1 to 45d93f4 Compare July 2, 2024 19:29
@kuhe kuhe merged commit 759bf43 into smithy-lang:main Jul 3, 2024
10 checks passed
@kuhe kuhe deleted the feat/idempotencyTokenHeader branch July 3, 2024 19:13
This pull request was closed.
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.

3 participants