Skip to content

[Hackathon] create-batch --run without --wait always exits 1 even when every trigger succeeds #161

Description

@kshitij-heizen

Discord Username / User ID

GitHub: @kshitij-heizen

Discord: spade1819

What does this improvement do?

Fixes test create-batch --run (without --wait) always exiting 1 even when every trigger succeeds — which breaks the documented exit-code contract and fails CI pipelines on fully successful dispatches.

The no-wait path returns each result with the trigger response's status, which is queued by design (src/commands/test.ts:2743-2756; the field is documented as "Terminal status if --wait; queued if no --wait" at src/commands/test.ts:1697). But the exit-code logic only recognizes terminal statuses (src/commands/test.ts:2910-2949):

const allPassed = batchRunResults.every(r => r.status === 'passed'); // queued → false
if (allPassed) return;
...
throw new CLIError(
  `Batch run finished: ${...} of ${...} run(s) did not pass.`,
  1,
);

Every no-wait result is queued, so allPassed is always false, no error exit codes exist, and the command falls through to exit 1 with a misleading "N of N run(s) did not pass".

Reproduction

testsprite test create-batch --plans ./plans.jsonl --run --output json
# stdout: results[] with every entry status:"queued", no errors
# stderr: "Batch run finished: 2 of 2 run(s) did not pass."
# exit code: 1  ← CI marks a fully successful dispatch as FAILED

This is the exact shape of the documented example (DOCUMENTATION.md create-batch section uses --run --max-concurrency 4 --output json, no --wait). It's also internally inconsistent: single test run <id> without --wait exits 0 on a successful queued dispatch.

Details / implementation notes

In the no-wait case, "success" means every trigger was dispatched without error — statuses are non-terminal by definition. Minimal fix in the exit-code block:

const allOk = opts.wait
  ? batchRunResults.every(r => r.status === 'passed')
  : batchRunResults.every(r => r.error === undefined);
if (allOk) return; // exit 0

Trigger errors in no-wait mode keep today's aggregation (uniform specific code, else exit 1), and the misleading "did not pass" message becomes "N of N trigger(s) failed" when --wait is absent. The stderr summary is likewise corrected for no-wait mode (it currently prints "0/N passed" for a fully successful dispatch).

Covered by unit tests in src/commands/test.create-batch-run.spec.ts (all-queued → resolves without error; partial trigger failure → still exits non-zero; --wait semantics unchanged). Existing no-wait specs only exercise error scenarios and never assert the success exit code, which is how this slipped through.

Not covered by existing issues: #153/#154/#156/#158 are TimeoutError/RequestTimeoutError stdout/classification asymmetries in run/rerun/wait; merged #130/#128 touched batch deadline sharing and idempotency-key output. Nothing claims the no-wait exit-code contract for create-batch --run.

PR to follow shortly.

Confirmations

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

in-progressAssigned and actively being worked on

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions