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

Function assertChainedRunKeyFits

src/commands/test.ts:555–570  ·  view source on GitHub ↗

* Chained `test create --run` / `test create --plan-from --run` derive the * trigger idempotency key as ` :run`. Validate that derived key * BEFORE the create POST so a near-limit user-supplied base key fails fast * (exit 5) instead of creating the test and THEN rejecting the 257+ char

(
  run: boolean | undefined,
  idempotencyKey: string | undefined,
)

Source from the content-addressed store, hash-verified

553 * `runCreate` / `runCreateFromPlan` when chaining into `runTestRun`.
554 */
555function assertChainedRunKeyFits(
556 run: boolean | undefined,
557 idempotencyKey: string | undefined,
558): void {
559 if (run !== true || idempotencyKey === undefined) return;
560 const RUN_SUFFIX = ':run';
561 if (idempotencyKey.length + RUN_SUFFIX.length > 256) {
562 throw localValidationError(
563 'idempotencyKey',
564 `must be at most ${256 - RUN_SUFFIX.length} characters when used with --run ` +
565 `(the chained trigger derives "<key>${RUN_SUFFIX}", which must stay within the 256-char limit)`,
566 undefined,
567 'flag',
568 );
569 }
570}
571
572/**
573 * B3 / Fix 4: best-effort duplicate-name advisory shared by `runCreate`

Callers 2

runCreateFunction · 0.85
runCreateFromPlanFunction · 0.85

Calls 1

localValidationErrorFunction · 0.70

Tested by

no test coverage detected