Skip to content

Commit

Permalink
Reject empty or blank idempotency keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cleve-fauna committed Jan 29, 2025
1 parent fb97192 commit 636cabf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/commands/export/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ function buildCreateS3ExportCommand(yargs) {
"Either --destination or both --bucket and --path are required to create an export.",
);
}
if (argv.idempotency?.trim() === "") {
throw new ValidationError("--idempotency cannot be an empty string.");
}
return true;
})
.example(sharedExamples);
Expand Down
10 changes: 10 additions & 0 deletions test/commands/export/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ idempotent_replayed: true
expectedError:
"Cannot specify --destination with --bucket or --path. Use either --destination or both --bucket and --path.",
},
{
description: "an empty string is given as the --idempotency input",
args: "--destination s3://test-bucket/test/key --idempotency ",
expectedError: "--idempotency cannot be an empty string.",
},
{
description: "an blank string is given as the --idempotency input",
args: "--destination s3://test-bucket/test/key --idempotency ' '",
expectedError: "--idempotency cannot be an empty string.",
},
];

invalidScenarios.forEach(({ description, args, expectedError }) => {
Expand Down

0 comments on commit 636cabf

Please sign in to comment.