MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / assertIdempotencyKey

Function assertIdempotencyKey

src/lib/validate.ts:160–180  ·  view source on GitHub ↗
(key: string | undefined)

Source from the content-addressed store, hash-verified

158 * @param key The raw flag value, or `undefined` when the key is auto-minted.
159 */
160export function assertIdempotencyKey(key: string | undefined): void {
161 if (key === undefined) return;
162 // ASCII-printable check: every codepoint must be in U+0020–U+007E (space through tilde).
163 // Non-ASCII chars (codepoint > 127) trigger a TypeError in Node's fetch ByteString header.
164 if (key.length === 0 || !/^[ -~]+$/.test(key)) {
165 throw localValidationError(
166 'idempotencyKey',
167 'must be 1–256 printable ASCII characters (no non-ASCII, control chars, or empty string)',
168 undefined,
169 'flag',
170 );
171 }
172 if (key.length > 256) {
173 throw localValidationError(
174 'idempotencyKey',
175 'must be at most 256 characters',
176 undefined,
177 'flag',
178 );
179 }
180}
181
182/**
183 * Assert that `arr` is an Array and that its length is within the given

Callers 12

runCreateFunction · 0.85
runPlanPutFunction · 0.85
runUpdateFunction · 0.85
runDeleteFunction · 0.85
runCreateFromPlanFunction · 0.85
runCreateBatchFunction · 0.85
runCodePutFunction · 0.85
runTestRunFunction · 0.85
runTestRunAllFunction · 0.85
runTestRerunFunction · 0.85
runCreateFunction · 0.85
runUpdateFunction · 0.85

Calls 1

localValidationErrorFunction · 0.70

Tested by

no test coverage detected