Repository navigation
[Hackathon] fix(cli): validate non-empty and non-whitespace IDs in schedule update, test diff, test wait, test open, and test flaky #468
Description
Verified against (commit SHA or released version)
commit 988c035 (main HEAD, v0.14.0)
Discord Username / User ID
3raiden/752124227720577094
What does this improvement do?
Several CLI commands that take positional resource IDs (<schedule-id>, <run-a>, <run-b>, <run-id...>, <test-id>) do not validate that those IDs are non-empty and non-whitespace before executing:
schedule update <schedule-id>(runUpdateinsrc/commands/schedule.ts:384):
src/commands/schedule.tsdefinesrequireScheduleId(raw: string): stringat line 500 and calls it inrunGet,runDelete,runTrigger, andrunRunList, but forgot to callrequireScheduleId(opts.scheduleId)inrunUpdate. Passing" "exits0under--dry-runand sendsPATCH /schedules/%20%20%20in live mode.test diff <run-a> <run-b>(runDiffinsrc/commands/test.ts:5746):
Never validatesopts.runAoropts.runB. Passing" "under--dry-runprintsverdicts differ: =passed vs =failedand exits0; in live mode it sendsGET /runs/%20%20%20.test wait <run-id...>(runTestWaitinsrc/commands/test.ts:9181andrunTestWaitManyinsrc/commands/test.ts:8675):
Neither single-run wait nor multi-run wait validates that every<run-id>is non-empty and non-whitespace. Under--dry-run,testsprite test wait " " --dry-runandtestsprite test wait " " " " --dry-runboth exit0with synthetic pass output; in live mode they poll/runs/%20%20%20.test flaky <test-id>(runFlakyinsrc/commands/test.ts:15223):
Line 15223 checksif (!opts.testId || opts.testId.length === 0)without.trim(), so whitespace-only<test-id>(" ") bypasses the guard, prints"path": "/api/cli/v1/tests/ /runs/rerun"under--dry-runwith exit0, and sendsPOST /tests/%20%20%20/runs/rerunin live mode.test open <test-id>(runOpeninsrc/commands/test.ts:6201):
Never validatesopts.testIdbefore callingclient.get('/tests/...')or constructing the browser dashboard URL.testsprite test open " " --dry-runexits0and outputshttps://www.testsprite.com/dashboard/tests/p_dryrun_2026/test/%20%20%20.
Note: Prior issues covered read-by-id commands (#368), testlist (#381), project env (#385), test run/cancel/delete-batch (#395), and project update/credential/auto-auth/sign-in (#466), leaving these 5 commands unguarded.
Details / implementation notes
Reproduction
Tested against commit 988c0355bb05631e9c6c1785e443937ff2a88c0e, built from source with Node v24.20.0 (offline, --dry-run):
testsprite schedule update " " --pause --dry-run
# Output: id: sch_dryrun_1 ... exit=0
testsprite test diff " " " " --dry-run
# Output: verdicts differ: =passed vs =failed ... exit=0
testsprite test wait " " --dry-run
# Output: {"dryRun":true,"action":"test.wait","method":"GET","path":"/api/cli/v1/runs/ ?waitSeconds=25",...} exit=0
testsprite test wait " " " " --dry-run
# Output: passed ... exit=0
testsprite test flaky " " --dry-run
# Output: {"dryRun":true,"action":"test.flaky","method":"POST","path":"/api/cli/v1/tests/ /runs/rerun",...} exit=0
testsprite test open " " --dry-run
# Output: https://www.testsprite.com/dashboard/tests/p_dryrun_2026/test/%20%20%20 exit=0Observed: All 5 commands exit 0 on whitespace-only IDs instead of rejecting with VALIDATION_ERROR (exit 5).
Expected: Each command rejects empty or whitespace-only positional IDs up front with typed VALIDATION_ERROR (exit 5) before constructing requests or emitting dry-run responses.
Proposed Fix
- In
src/commands/schedule.ts(runUpdate, line 384): callconst scheduleId = requireScheduleId(opts.scheduleId);up front and usescheduleIdin thePATCHpath. - In
src/commands/test.ts:runDiff(line 5746): validateopts.runA(requireNonEmptyId(opts.runA, '<run-a>')) andopts.runB(requireNonEmptyId(opts.runB, '<run-b>')) up front.runTestWait(line 9181) andrunTestWaitMany(line 8675): validateopts.runIdand every item inopts.runIdswithrequireNonEmptyId(..., '<run-id>')up front.runFlaky(line 15223): check!opts.testId || opts.testId.trim().length === 0(and use the trimmed ID).runOpen(line 6201): validaterequireNonEmptyId(opts.testId, '<test-id>')up front.
- Add unit tests in
src/commands/schedule.spec.tsandsrc/commands/test.spec.tscovering empty and whitespace-only IDs in both live and--dry-runmodes.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
ruili-testsprite commentedon Oct 20, 2026
Closing as a duplicate of #368. Its scope now covers empty and whitespace-only positional ids for every command in one change, including the commands listed here. Thanks for the report! If you'd like to work on it, comment
/assignon #368.