Repository navigation
Description
Verified against (commit SHA or released version)
commit d61e6dfc400f5e88ee34ac799c5496ac5c5a7751 (main, v0.15.0)
Discord Username / User ID
okey_amy
What does this improvement do?
test create and test update document --produces <var> / --needs <var> as variable-name declarations, and --category as a backend wave category. The CLI validates whether those flags are applicable to the test type, but never validates their values. Empty strings and whitespace-only strings are accepted with exit 0 and copied verbatim into the request body.
--category is free-text in the implementation (src/commands/test.ts:1282, :2370), so this report does not ask to reject non-empty values such as bogus. It asks to reject empty values and to reconcile the documentation, which currently presents --category <setup|main|teardown> while the help text calls it free-text and mentions cleanup.
The same functions already validate their other constrained inputs (--name, --description length, --priority, --step-timeout, and the mutual exclusion of the two timeout flags). These three fields are the gap.
Details / implementation notes
runUpdate (src/commands/test.ts:2397) validates name, description, priority, and stepTimeoutMs, but never inspects the elements of produces / needs or the value of category. The body is built verbatim:
src/commands/test.ts:2476—if (hasProduces) body.produces = opts.produces!;src/commands/test.ts:2477—if (hasNeeds) body.consumes = opts.needs!;src/commands/test.ts:2478—if (hasCategory) body.category = opts.category!;
runCreate has the same pattern at src/commands/test.ts:1581-1588. It does correctly reject backend-only flags when --type frontend is used (src/commands/test.ts:1525-1538), so the applicability check exists; only the value checks are missing.
In live mode against a permissive mock, the CLI sends:
{"produces":[""],"category":""}for test update test_x --produces "" --category "", and the same shape for test create. No client-side error is raised.
The existing test at src/commands/test.test.ts:7627 covers empty arrays (the flag was omitted) being left off the wire. It does not cover an explicitly empty string element, which is why --produces "" still reaches the request.
Repro
# All local (--dry-run): no network or credentials needed.
$ testsprite test update test_x --produces "" --dry-run --output json; echo "exit=$?"
# { "testId": "test_dryrun_update_2026", "updatedFields": ["produces"], ... }
# exit=0
$ testsprite test update test_x --needs " " --dry-run --output json; echo "exit=$?"
# updatedFields: ["consumes"], exit=0
$ testsprite test update test_x --category "" --dry-run --output json; echo "exit=$?"
# updatedFields: ["category"], exit=0
$ testsprite test create --project proj_x --type backend --name n \
--code-file code.py --produces "" --dry-run --output json; echo "exit=$?"
# exit=0Control: test create --type frontend --produces x ... correctly exits 5 with "--produces is a backend-only flag", so the command does validate flag applicability, just not the value.
Expected
--produces/--needsvalues are trimmed; empty or whitespace-only values are rejected locally withVALIDATION_ERROR/ exit 5 and adetails.fieldnaming the flag.--category ""(or whitespace-only) is rejected the same way. Non-empty free-text categories keep working, includingsetup,main,teardown, andcleanup.DOCUMENTATION.md:383and:420describe--categoryas free-text (--category <str>, withteardown/cleanupmarking a final-wave cleanup test) so docs and--helpagree. No non-empty category value is removed.
Actual
Every value is accepted, and the request body carries it verbatim. The server is the only validator, so the user either gets a late API error after the write attempt or, if the server accepts it, a test whose dependency declaration is not what the docs describe.
Impact
--produces / --needs drive dependency-aware wave ordering on test rerun and test run --all. An empty or whitespace-only variable name cannot match a real producer/consumer, so the ordering the user asked for silently does not happen (or the run fails later, far from the flag). An empty --category similarly drops the final-wave marker the user meant to set. The failure is far from the command that caused it, which is exactly the kind of late validation the CLI avoids for its other flags.
Suggested fix
In runUpdate and runCreate, before building the body:
- trim each
--produces/--needselement; throwlocalValidationError('produces'|'needs', ...)for empty/whitespace values; - trim
--category; throwlocalValidationError('category', ...)for an empty value; - keep the existing behavior for all non-empty values and for omitted flags;
- update
DOCUMENTATION.md:383and:420to describe--categoryas free-text and include thecleanupconvention already in--help.
Add tests in src/commands/test.test.ts that fail on d61e6df: empty --produces, whitespace --needs, and empty --category for create and update, plus valid-value controls (including a non-empty free-text category such as auth).
Related work
- [Hackathon] fix(project): project auto-auth doesn't validate --login-method / --login-content-type — invalid values are sent as-is #539 applies the same validation principle to
project auto-auth --login-method/--login-content-type. The equivalent check is still missing on the test dependency declarations. - [Hackathon] fix(cli): endpoint URLs with credentials,
?queryor#fragmentpass validation, andci init --projectskips validation entirely #444 is about endpoint URLs with credentials/query/fragment; this report is about the three test flags. - [Hackathon] fix(test):
test lintpasses plans thattest create/create-batchreject, and fails ones they accept #374 is abouttest lint/test createparity on plans; it does not cover value validation for these flags. - [Hackathon] fix(test): flags documented "with --history / --run / --all" are silently ignored without that flag (their siblings exit 5) #376 is about flags being ignored without their enabling flag; here the values are accepted but not validated.
Scope
Limited to empty/whitespace validation for --produces, --needs, and --category on test create and test update, plus the --category docs wording. Non-empty values and omitted flags keep their current behavior.
Environment
CLI version: 0.15.0 (d61e6dfc400f5e88ee34ac799c5496ac5c5a7751)
Node: v22.23.1
OS: Linux x86_64
Confirmations
- I checked the existing issue list and linked the closest items under Related work.
- I have provided my Discord identity above for reward coordination.
Activity
[-][Hackathon] fix(test): test create/update send empty or out-of-set --produces/--needs/--category values[/-][+][Hackathon] fix(test): test create/update accept empty `--produces`/`--needs` and empty `--category` values[/+]ruili-testsprite commentedon Oct 31, 2026
Thanks @OkeyAmy, confirmed: blank
--produces,--needsand--categoryvalues are sent as empty strings. #577, #582, #604, #646 and #663 all come from the same place, a blank option value read as an omitted one, so we'll fix it once for every option ourselves instead of flag by flag. Closing as not planned.