Skip to content

[Hackathon] fix(test): test steps --run-id accepts invalid --page-size / --max-items values and skips the bare path's validation #603

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 steps <test-id> --run-id <run-id> takes a different code path from the bare test steps <test-id> read. The run-scoped path returns before validatePaginationFlags() runs, so:

  • invalid pagination values are accepted with exit 0 (--page-size 0, --page-size 101, --max-items 0);
  • valid values are silently ignored (--max-items 1 returns both steps; --starting-token is never sent);
  • the bare path correctly rejects the same invalid values with VALIDATION_ERROR / exit 5.

The docs say the common pagination flags have the "same shape as the other lists" (DOCUMENTATION.md:292), and --help says --page-size is 1-100 and --max-items stops after N items. Neither is true on the --run-id path.

The code comment on StepsOptions (src/commands/test.ts:5716-5718) says the flags are intentionally ignored with --run-id because the run-scoped endpoint returns all steps in one response. That intent is reasonable, but it is not reflected in the user-facing help/docs, and the early return also bypasses the invalid-value checks.

Details / implementation notes

runSteps early-returns for opts.runId before the pagination validation:

  • src/commands/test.ts:6352 — if (opts.runId !== undefined) {
  • src/commands/test.ts:6372-6374 — maps every run.steps row and returns { items, nextToken: null } without applying maxItems
  • src/commands/test.ts:6397 — validatePaginationFlags(...) is only reached on the bare path

The run-scoped response is intentionally unpaginated (nextToken: null, documented at DOCUMENTATION.md:290), so the right fix may be to reject pagination flags with --run-id rather than apply them. Either way, silently accepting invalid values and silently ignoring --max-items is not the documented contract.

Repro

All commands below are local (--dry-run), so no network or credentials are needed.

# Control: the bare path validates and honors --max-items.
$ testsprite test steps test_x --max-items 1 --dry-run --output json | jq '.items | length'
1
$ testsprite test steps test_x --max-items 0 --dry-run --output json; echo "exit=$?"
# VALIDATION_ERROR: Flag `--max-items` is invalid: must be a positive integer.
# exit=5

# Run-scoped path: both are accepted, and --max-items is ignored.
$ testsprite test steps test_x --run-id run_x --max-items 1 --dry-run --output json | jq '.items | length'
2
$ testsprite test steps test_x --run-id run_x --max-items 0 --dry-run --output json; echo "exit=$?"
# exit=0
$ testsprite test steps test_x --run-id run_x --page-size 0 --dry-run --output json; echo "exit=$?"
# exit=0
$ testsprite test steps test_x --run-id run_x --page-size 101 --dry-run --output json; echo "exit=$?"
# exit=0

Against a permissive mock backend, the same run-scoped invocations make only GET /api/cli/v1/runs/run_x?includeSteps=true; --page-size and --starting-token never appear in the request, and --max-items 1 still returns both steps.

Expected

  • --page-size 0, --page-size 101, and --max-items 0 are rejected locally with VALIDATION_ERROR / exit 5, exactly as on the bare path.
  • Valid pagination flags may keep their current intentional behavior (ignored, because the run-scoped response is unpaginated), but test steps --help and DOCUMENTATION.md must say so. A user who passes --max-items 1 should not be led to expect one item.
  • --starting-token is documented as ignored with --run-id (or rejected); it must not be silently accepted under a help text that presents it as active.

Actual

The run-scoped branch returns before validation; every value is accepted and --max-items/--starting-token have no effect.

Impact

A script or agent that bounds step output with --max-items gets the full list instead, which can make CI logs and agent context much larger than requested. Typos such as --page-size 0 that the bare path catches are silently accepted on the run-scoped path, so the same command behaves differently depending on whether --run-id is present. The output-shape bug (--max-items 1 returning two items) is user-visible even when the flag is valid.

Suggested fix

In runSteps, run the same validatePaginationFlags() check before the --run-id early return. That is the minimal fix for the invalid-value defect and does not change the intentional unpaginated behavior for valid flags. Then add a short note to test steps --help and DOCUMENTATION.md:290-292 that --page-size, --starting-token, and --max-items do not apply with --run-id.

Add tests to src/commands/test.test.ts covering --run-id --page-size 0 / --max-items 0 (exit 5), a valid --run-id --max-items 1 control (still returns both items and exits 0, now documented), and the bare-path control (already exit 5). The invalid-value tests should fail on d61e6df.

Related work

Scope

Limited to the --run-id branch of test steps. The bare test steps <test-id> path already validates and honors the pagination flags.

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 steps --run-id silently ignores --max-items/--page-size and skips their validation[/-] [+][Hackathon] fix(test): `test steps --run-id` accepts invalid `--page-size` / `--max-items` values and skips the bare path's validation[/+] 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, the --run-id path does skip those checks, but with --run-id all of the run's steps come back in one response, so --page-size and --max-items have nothing to page and the full list is printed either way. 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