Skip to content

[Hackathon] fix(test): test create/update accept empty --produces/--needs and empty --category values #604

Closed as not planned

Description

@OkeyAmy

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=0

Control: 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 / --needs values are trimmed; empty or whitespace-only values are rejected locally with VALIDATION_ERROR / exit 5 and a details.field naming the flag.
  • --category "" (or whitespace-only) is rejected the same way. Non-empty free-text categories keep working, including setup, main, teardown, and cleanup.
  • DOCUMENTATION.md:383 and :420 describe --category as free-text (--category <str>, with teardown/cleanup marking a final-wave cleanup test) so docs and --help agree. 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 / --needs element; throw localValidationError('produces'|'needs', ...) for empty/whitespace values;
  • trim --category; throw localValidationError('category', ...) for an empty value;
  • keep the existing behavior for all non-empty values and for omitted flags;
  • update DOCUMENTATION.md:383 and :420 to describe --category as free-text and include the cleanup convention 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

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

  1. changed the title [-][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[/+] on Oct 20, 2026
  2. added
    needs-triage
    hackathon
    on Oct 30, 2026
  3. removed
    needs-triage
    on Oct 31, 2026
  4. ruili-testsprite commented on Oct 31, 2026

    @ruili-testsprite
    Contributor

    Thanks @OkeyAmy, confirmed: blank --produces, --needs and --category values 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions