Skip to content

fix(test): verify batch in-flight run compatibility before attaching - #607

Merged
zeshi-du merged 2 commits into
TestSprite:mainfrom
yeziR4:fix/batch-attach-environment
Nov 10, 2026
Merged

zeshi-du merged 2 commits into
TestSprite:mainfrom
yeziR4:fix/batch-attach-environment

Conversation

@yeziR4

@yeziR4 yeziR4 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

test create-batch --run --wait previously attached to any 409 run_in_flight run ID, even if that run used a different environment or target URL. It now checks compatibility with the existing verifyInFlightRunEnvironment helper before attaching, matching the fresh batch-run path.

Environment listings are cached per project for the batch. Mismatches and unverifiable explicitly requested targets remain per-test CONFLICT rows (exit 6), with a test wait <run-id> hint in the existing message field. The attached run descriptor uses the stored target URL instead of the requested URL. Legacy unreadable-run attachment without flags is preserved.

Related issue

Closes #387

Season 4 CLI Improvement Bonus

  • I'm entering this PR for the Season 4 CLI Improvement Bonus

Discord username: ___h___r

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Validation

  • Entire create-batch run suite: 60 tests passed, including 11 new compatibility cases.
  • Covers named/default environment matches and mismatches, missing/null environment, target URL match/mismatch, unreadable metadata, legacy no-flag attachment, listing failure, and one shared verification lookup for two runs in a project.
  • New regression cases fail before the fix; refused runs receive no subsequent poll.
  • Lint, formatting and typecheck passed (existing lint warnings, no errors). Full suite: 122 files passed.
  • Coverage: lines 92.14%, statements 89.96%, branches 84.99%, functions 83.65%.

Notes for reviewers

Poll/tail handling, JSON shape, unrelated exit codes and tunnel attachment exclusion are unchanged. Codex assisted with implementation and validation.

Summary by CodeRabbit

  • Bug Fixes
    • Batch test runs now resume an in-flight run only when its environment and target URL are compatible with the request.
    • Default environments are matched correctly, and runs with unreadable details are attached only when no requested environment or target needs verification.
    • Incompatible runs or environment lookup failures now produce a conflict error with recovery guidance.
    • Resumed results retain the in-flight run’s target URL when available.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

Batch runs now check an in-flight run’s environment and target URL before attaching. Incompatible or unverifiable conflicts return an error instead of attaching. Tests cover matching and mismatching values, unreadable runs, and environment-listing failures.

Changes

Batch Run Conflict Verification

Layer / File(s) Summary
Verify conflict compatibility before attachment
src/commands/test.ts, src/commands/test.create-batch-run.spec.ts
The batch runner reads the in-flight run and checks its environment against the requested environment or project default. When a target URL is requested, it also checks for a match. Failed or unavailable verification returns a CONFLICT error with recovery guidance. Environment listings are cached per project. Resumed responses use the in-flight run’s target URL when available. Tests cover compatible and incompatible conflicts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Merge Risk: Low · up to 29e57

A single transient error while verifying an in-flight run can cause other compatible runs in the same batch to be reported as conflicts instead of being attached. This is a narrow, fail-safe edge case, so the change is mergeable with a small follow-up.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: verifying batch in-flight run compatibility before attachment.
Linked Issues check Passed Issue #387 requires compatibility checks before a batch --wait attachment. The PR summary states that verifyInFlightRunEnvironment checks the requested or project-default environment and treats mi…
Out of Scope Changes check Passed The reported source changes are limited to batch in-flight-run verification, environment-list caching required for that verification, stored target URL propagation, and related regression tests. Legac…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Full details: Linked Issues check

Explanation

Issue #387 requires compatibility checks before a batch --wait attachment. The PR summary states that verifyInFlightRunEnvironment checks the requested or project-default environment and treats missing or null metadata as incompatible. It also states that a requested --target-url must match strictly. Rejected attachments produce per-test CONFLICT rows with exit code 6 and no subsequent poll. Accepted attachments use the stored target URL. The added tests cover matching, mismatching, missing/null, unreadable metadata, target URL, listing failure, and no-poll behavior.

Full details: Out of Scope Changes check

Explanation

The reported source changes are limited to batch in-flight-run verification, environment-list caching required for that verification, stored target URL propagation, and related regression tests. Legacy no-flag attachment behavior and existing poll, output, exit-code, and tunnel behavior remain preserved. These changes support issue #387 or preserve required compatibility. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 too large.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Repository: TestSprite/testsprite-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: adcee115-f6f8-469f-b736-7c84f18c062c
📥 Commits

Reviewing files that changed from the base of the PR and between d61e6df and 29a3291.

📒 Files selected for processing: 2

  • src/commands/test.create-batch-run.spec.ts
  • src/commands/test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@github-actions

Copy link
Copy Markdown

🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @yeziR4!

To be counted, this PR needs the following by Oct 29, 11:59 PM PT:

  • ✅ A linked issue assigned to you.
  • ✅ Out of draft.
  • ✅ A Discord username in the description.

Rewards go to merged PRs judged a genuine improvement, and up to three bonus-eligible PRs count per person. Untick the box to withdraw the entry. This comment refreshes when you edit the PR. Full rules.

@github-actions github-actions Bot added the s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus label Oct 22, 2026
@jangjos-128 jangjos-128 added the hackathon CLI hackathon submissions label Oct 29, 2026
@zeshi-du
zeshi-du merged commit bb780d7 into TestSprite:main Nov 10, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hackathon CLI hackathon submissions s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] fix(test): batch --wait 409 auto-attach skips the environment/targetUrl checks the single-run path enforces

3 participants