Repository navigation
Description
Verified against (commit SHA or released version)
commit 988c035 (v0.14.0)
Discord Username / User ID
weili_yang33
What does this improvement do?
Summary
When a batch create-and-run under --wait hits 409 run_in_flight for a test, runBatchRun attaches to the in-flight run by currentRunId without checking that the run's environment matches the requested --env, or that its target URL matches the requested --target-url. The batch then reports the in-flight run's verdict as if it were this invocation's result. The single-run path (runTestRun) validates both before attaching and refuses with incompatibleRun — the batch path skips that validation entirely.
What happened
src/commands/test.ts:4594-4633—runBatchRun'striggerOnecatches409run_in_flight, takescurrentRunIdfrom the error details, builds a synthetictriggerResponse(itstargetUrlfield is even filled with the requested value, not the running run's), and attaches the poll. The only guard is a tunnel-target exclusion; there is no environment comparison and no targetUrl comparison.src/commands/test.ts:8030-8186— the singletest runpath handles the same 409 by validating the in-flight run's environment against--env(null/missing counts as a mismatch) and requiring strict targetUrl equality before attaching, with a comment explaining that attaching blindly would "report a different environment's verdict as if it were the local one".
The batch path dispatches environment/targetUrl in its trigger body (test.ts:4470-4477), so the information needed for the same check is available there too.
Reproduction
- Test
Talready has a run in flight against the project default environment (started elsewhere). - Run a batch that targets a different environment:
$ testsprite test create-batch --plans plans.jsonl --run --wait --env stagingwhere plans.jsonl re-declares T (same project, new spec), so the server answers 409 run_in_flight with the default-environment run's currentRunId.
- The CLI attaches silently, polls the default-environment run to a verdict, and reports it as the outcome of this
--env stagingbatch. The exit code and JSONresults[]carry the wrong environment's verdict. The single-run command in the same situation refuses withincompatibleRuninstead.
Expected
The batch attach path should apply the same checks as runTestRun: verify the in-flight run's environment matches the requested --env (treating null/missing as a mismatch) and, when a --target-url was requested, require strict equality. On mismatch, do not attach — surface the conflict (exit 6) instead of reporting a foreign verdict.
Related
- [Hackathon] batch rerun swallows exit codes and never escalates auth failures #78 and the current C1-class work both touch the batch
--waittails; this is a distinct defect at the attach step, before polling starts.
Details / implementation notes
The fix can reuse the validation block from runTestRun's 409 handler (the poll-fetch of the in-flight run's environment/targetUrl) as a shared helper for both paths. The existing batch 409 tests in test.create-batch-run.spec.ts provide the harness; the single-run attach tests in test.run.spec.ts show the mismatch assertions to mirror. Happy to pick this up.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
zeshi-du commentedon Oct 20, 2026
Thanks @Herbicide7665, accepted, with a narrower scope. In v0.15.0
test run --all --waitalready has this gate (runTestRunAllresume check usingverifyInFlightRunEnvironment). The gap is onlycreate-batch --run --wait: the 409run_in_flighthandler inrunBatchRunattaches bycurrentRunIdwith no environment/targetUrl check. Please retitle the issue accordingly.Scope:
verifyInFlightRunEnvironment, mirroring therunTestRunAllgate (per-batch cached env listing per project).CONFLICTerror row (exit 6) withtest wait <run-id>as next step. Other exit codes and no-flag attach behaviour unchanged.targetUrlfrom the request when attaching.Feel free to claim it with /assign.
yeziR4 commentedon Oct 20, 2026
/assign
I will implement the accepted create-batch-only environment/target URL compatibility check, reusing verifyInFlightRunEnvironment and the existing per-test conflict row, with mocked regression tests. Discord: ___h___r
testsprite-hob commentedon Oct 20, 2026
Assigned to @yeziR4. Thanks for taking this on. (0 more slots available.)
Your open assigned issues (3/3):
fix(test): verify batch in-flight run compatibility before attaching (T…