Skip to content

[Hackathon] fix(testlist): validate non-empty and non-whitespace IDs across testlist commands #381

Closed as duplicate

Description

@naufalfx805-source

Verified against (commit SHA or released version)

commit 988c0355bb05631e9c6c1785e443937ff2a88c0e — @testsprite/testsprite-cli 0.14.0

Discord Username / User ID

@npall_805

What does this improvement do?

The testlist command group (testlist get, testlist delete, testlist run, testlist add, testlist remove, and testlist update) does not validate that positional <list-id> and <test-id...> arguments are non-empty and non-whitespace before proceeding.

When a positional argument is whitespace (e.g. testsprite testlist get " " or testsprite testlist run "$LIST_ID" where $LIST_ID is unpopulated or whitespace):

  1. Under --dry-run: The CLI immediately prints canned success samples (ID: tl_dryrun, Deleted test list , or dry-run: no runs dispatched) and exits 0, giving a false-pass signal on invalid input.
  2. In live mode: The CLI interpolates the unvalidated whitespace into the REST endpoint path (e.g. /testlist/%20%20%20/cases or /testlist/%20%20%20), leaking raw server 400/404 responses or timeout errors instead of failing fast locally with a typed VALIDATION_ERROR (exit 5).
  3. In mutateCases (testlist add / testlist remove): While opts.testIds.length === 0 is checked, passing whitespace elements ([" "]) bypasses the length check and reaches the API.

In contrast, sibling commands such as test delete, project delete, and test update validate positional IDs up front and throw VALIDATION_ERROR (<flag> is required, exit 5).

Details / implementation notes

Proposed Solution:

  1. Add helper assertValidListId in src/commands/testlist.ts throwing typed localValidationError('list-id', 'is required and must not be empty or whitespace-only', undefined, 'field') (exit code 5).
  2. Validate listId at entry in runTestlistGet, runTestlistDelete, runTestlistUpdate, runTestlistRun, and mutateCases.
  3. In mutateCases, validate that each element in opts.testIds is non-empty and non-whitespace.
  4. In validateTestlistRunOptions, validate that each --case element is non-empty and non-whitespace.
  5. Add comprehensive unit test suite in src/commands/testlist.spec.ts asserting that empty and whitespace arguments throw VALIDATION_ERROR (exit 5) across both live and --dry-run modes.

Branch is ready with all tests passing locally.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. naufalfx805-source commented on Oct 12, 2026

    @naufalfx805-source
    ContributorAuthor

    /assign

  2. testsprite-hob commented on Oct 12, 2026

    @testsprite-hob

    Thanks for the interest, @naufalfx805-source! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it accepted once it is). Feel free to check back, or ping us on Discord if it's been quiet.

  3. naufalfx805-source commented on Oct 19, 2026

    @naufalfx805-source
    ContributorAuthor

    /assign

  4. testsprite-hob commented on Oct 19, 2026

    @testsprite-hob

    Thanks for the interest, @naufalfx805-source! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it accepted once it is). Feel free to check back, or ping us on Discord if it's been quiet.

  5. ruili-testsprite commented on Oct 20, 2026

    @ruili-testsprite
    Contributor

    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 /assign on #368.

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

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions