Repository navigation
Description
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 1returns both steps;--starting-tokenis 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 everyrun.stepsrow and returns{ items, nextToken: null }without applyingmaxItemssrc/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=0Against 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 0are rejected locally withVALIDATION_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 --helpandDOCUMENTATION.mdmust say so. A user who passes--max-items 1should not be led to expect one item. --starting-tokenis 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
- [Hackathon] fix(test): flags documented "with --history / --run / --all" are silently ignored without that flag (their siblings exit 5) #376 addresses flags being ignored when their enabling flag is absent. Here
--run-idis present, and the pagination flags are ignored on that branch; [Hackathon] fix(test): flags documented "with --history / --run / --all" are silently ignored without that flag (their siblings exit 5) #376's table does not listtest steps --run-id, so this is an adjacent case rather than a repeat. - [Hackathon] Bound Response Buffering (Large Histories/Steps Load Fully into Heap) #83 / [Hackathon] Bound aggregate payload retention in buffered pagination (follow-up to #83) #517 cover the memory side of large
getRun({ includeSteps: true })responses. This report is about the flag contract that decides how many rows are returned, and about rejecting invalid values before the request. - [Hackathon] project list should validate pagination flags before auth/client setup #148 (closed) is the precedent for validating pagination flags before the path that uses them (
project list).
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
[-][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[/+]ruili-testsprite commentedon Oct 31, 2026
Thanks @OkeyAmy, the
--run-idpath does skip those checks, but with--run-idall of the run's steps come back in one response, so--page-sizeand--max-itemshave nothing to page and the full list is printed either way. Closing as not planned.