Skip to content

[Hackathon] fix(project): validate non-empty and non-whitespace <project-id> across project env commands #385

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 project env command group (project env list, project env get, project env create, project env update, project env delete, and project env set-default) accepts a positional <project-id> argument but does not validate that it is non-empty and non-whitespace before proceeding.

When a positional <project-id> argument is empty or whitespace (e.g. testsprite project env list "$PROJECT_ID" or testsprite project env get " " prod when an environment variable is unset or whitespace):

  1. Under --dry-run: The CLI immediately prints canned synthetic responses (e.g. sampleEnv, deleted: prod, etc.) and exits 0, providing a false-success indicator on an invalid project identifier.
  2. In live mode: The unvalidated empty/whitespace argument is directly interpolated into the REST path (e.g. /projects/%20%20%20/env or /projects//env), sending malformed requests to the backend API rather than failing fast locally with a typed VALIDATION_ERROR (exit 5).

In contrast, sibling commands such as project delete explicitly validate <project-id> up front and throw VALIDATION_ERROR (<project-id> is required and must not be empty or whitespace-only, exit 5).

Details / implementation notes

Proposed Solution:

  1. Add requireProjectId(raw: string | undefined): string in src/commands/project-env.ts throwing typed localValidationError('<project-id> is required and must not be empty or whitespace-only', '<project-id>') (exit 5, VALIDATION_ERROR).
  2. Call requireProjectId up front in:
    • runEnvList
    • runEnvGet
    • runEnvCreate
    • runEnvUpdate
    • runEnvDelete
    • runEnvSetDefault
  3. Add unit test suite in src/commands/project-env.spec.ts asserting that empty and whitespace project IDs consistently reject with code 5 (VALIDATION_ERROR) across all 6 commands in both live and --dry-run modes.

Branch is ready with all tests and formatting verified.

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