Skip to content

[Hackathon] fix(schedule): validate --columns up front in schedule list and schedule run list before API calls and empty-list returns #467

Closed

Description

@grzdev

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?

schedule list (runList in src/commands/schedule.ts:181-194) and schedule run list (runRunList in src/commands/schedule.ts:510-530) accept --columns <keys> in text output mode (--output text), but unlike every other list command in the CLI (project list, test list, test result --history, and testlist list), they do not call resolveTextColumns(opts.columns, ...) up front before creating the HTTP client or making network requests.

This causes three concrete bugs:

  1. Silent false-success (exit 0) when the schedule or run list is empty:
    In renderScheduleListText (src/commands/schedule.ts:581-590) and renderRunListText (src/commands/schedule.ts:690-715), when schedules.length === 0 or runs.length === 0, the formatter returns 'No schedules.' / 'No runs for schedule <id>.' before renderTextTable is ever called. As a result, passing a completely invalid column name like testsprite schedule list --columns bogus or testsprite schedule run list sch_1 --columns bogus on an account/schedule with 0 items silently succeeds with exit code 0 instead of failing with VALIDATION_ERROR (exit 5).
  2. Unnecessary authenticated network round-trip on invalid CLI flags:
    When schedules.length > 0 or runs.length > 0, runList and runRunList still execute GET /schedules or GET /schedules/{id}/runs over the network (requiring valid credentials and hitting the remote API) before renderTextTable finally rejects the invalid --columns flag.
  3. Leaked dry-run sample notice before validation failure:
    Under --dry-run, makeClient runs first and emits [dry-run] sample response — not from the server to stderr before renderTextTable throws VALIDATION_ERROR (exit 5).

In contrast, all sibling list commands validate --columns up front before makeClient or empty-list early returns:

  • project list (src/commands/project.ts:164-166): calls resolveTextColumns(opts.columns, PROJECT_LIST_COLUMNS) at the top of runList.
  • test list (src/commands/test.ts:5088) and test result --history (src/commands/test.ts:6155): call resolveTextColumns up front.
  • testlist list (src/commands/testlist.ts:177-179): calls resolveTextColumns(opts.columns, TESTLIST_COLUMNS) up front with comment // validate up front (exit 5 on a bad key).

Details / implementation notes

Reproduction

Tested against commit 988c0355bb05631e9c6c1785e443937ff2a88c0e, built from source with Node v24.20.0:

  1. Compare --dry-run behavior between project list / testlist list and schedule list / schedule run list:
# Sibling commands fail fast before makeClient (no dry-run notice emitted):
testsprite project list --columns bogus --dry-run
# stderr: Error: Invalid request. Unknown column "bogus". Valid columns: id, name, type, createdAt, updatedAt
# exit=5

# schedule list and schedule run list call makeClient and fetch first, emitting the dry-run notice before failing:
testsprite schedule list --columns bogus --dry-run
# stderr: [dry-run] sample response — not from the server
# stderr: Error: Invalid request. Unknown column "bogus". Valid columns: id, name, projectId, cron, timezone, target, status, nextRunAt, lastRunVerdict
# exit=5

testsprite schedule run list sch_1 --columns bogus --dry-run
# stderr: [dry-run] sample response — not from the server
# stderr: Error: Invalid request. Unknown column "bogus". Valid columns: runId, status, verdict, triggeredAt, startedAt, completedAt, duration, passRate, reportUrl
# exit=5
  1. When the API returns an empty list (items: []), renderScheduleListText (src/commands/schedule.ts:585) and renderRunListText (src/commands/schedule.ts:694) return early before renderTextTable runs, so schedule list --columns bogus and schedule run list sch_1 --columns bogus exit 0 (No schedules. / No runs for schedule sch_1.) without ever validating --columns.

Expected:
Both schedule list and schedule run list validate opts.columns up front (when opts.output === 'text') via resolveTextColumns, rejecting unknown or empty column keys with VALIDATION_ERROR (exit 5) before constructing the HTTP client, emitting dry-run notices, making API requests, or taking empty-list early returns.

Proposed Fix

  1. Import resolveTextColumns from ../lib/text-table.js in src/commands/schedule.ts.
  2. In runList (src/commands/schedule.ts:181), before makeClient(opts, deps):
if (opts.output === 'text') {
  resolveTextColumns(opts.columns, SCHEDULE_LIST_COLUMNS);
}
  1. In runRunList (src/commands/schedule.ts:510), right after requireScheduleId(opts.scheduleId) and before makeClient(opts, deps):
if (opts.output === 'text') {
  resolveTextColumns(opts.columns, SCHEDULE_RUN_LIST_COLUMNS);
}
  1. Add unit tests in src/commands/schedule.spec.ts verifying that invalid --columns values in schedule list and schedule run list reject with exit 5 (VALIDATION_ERROR) without calling fetch (including when the server would return an empty list or in --dry-run mode).

Confirmations

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

Activity

  1. added
    needs-triage
    hackathon
    on Oct 17, 2026
  2. zeshi-du commented on Oct 20, 2026

    @zeshi-du
    Contributor

    Thanks @grzdev — confirmed on v0.15.0 and accepted. schedule.ts never calls resolveTextColumns, so schedule list and schedule run list skip --columns validation until render time, and never when the list is empty.

    Scope:

    • In runList and runRunList, validate --columns in text mode before the client is created, as project list and testlist list do.
    • A bad key gives VALIDATION_ERROR (exit 5) with no request, no dry-run banner, and no empty-list exit 0.
    • JSON output behavior stays unchanged.
    • Tests for both commands, covering an empty server list and --dry-run. They should fail before the fix.

    Comment /assign to claim it.

  3. added
    accepted
    and removed
    needs-triage
    on Oct 20, 2026
  4. grzdev commented on Oct 20, 2026

    @grzdev
    ContributorAuthor

    /assign

  5. added
    in-progress
    on Oct 20, 2026
  6. testsprite-hob commented on Oct 20, 2026

    @testsprite-hob

    Assigned to @grzdev. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

  7. added a commit that references this issue on Nov 10, 2026
    1669720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedhackathonin-progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions