Skip to content

Fix setup-connect E2E pending approval leak - #892

Merged
shanselman merged 1 commit into
mainfrom
shanselman-fix-setup-e2e-flake
Jun 30, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-fix-setup-e2e-flake

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Summary

Fixes the setup-connect E2E order/race flake by cleaning up pending gateway approval requests created by the external-tray setup scenarios.

The external QR/shared-token tests now:

  • snapshot pending device/node approval IDs before creating an external tray
  • dispose the external tray before cleanup so it stops emitting delayed requests
  • reject only newly-created unhandled pending approvals until the shared gateway stays quiet
  • track requests already approved/rejected by the test body to avoid double decisions
  • avoid masking the original test failure if best-effort cleanup also fails

This preserves the healthy-state checks that require no pending requests; it cleans up the source of the leak instead of weakening AssertNoPendingRequests.

Prior failing job evidence

The flaky GitHub Actions setup-connect shard failed twice after PR #891 was patched in:

  • OpenClaw.E2ETests.Setup.SetupAndConnectTests.RealGateway_SharedTokenFlow_ReconnectsThroughTrayMcp
  • OpenClaw.E2ETests.Setup.SetupAndConnectTests.RealGateway_BadSharedToken_DoesNotDestroyExistingPairing

Both failures were from AssertNoPendingRequests expecting 0 pending requests and finding 1. The failing log also showed a negative shared-token connect response:

{"outcome":"ConnectionFailed","error":"unauthorized: gateway token mismatch (set gateway.remote.token to match gateway.auth.token)"}

and a node list with two Windows node entries, one offline, consistent with an earlier external-tray scenario leaving shared gateway state behind.

Validation

  • ./build.ps1 - passed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore - passed: 2659 passed, 31 skipped
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore - passed: 1443 passed

Initial --no-restore test attempts hit the documented fresh-worktree missing-assets case, so I ran the same test projects once without --no-restore to restore/build, then reran the required --no-restore commands above successfully.

Real behavior proof

  • Focused setup-connect E2E was attempted locally with:
$env:OPENCLAW_REPO_ROOT=(Get-Location).Path
$env:OPENCLAW_RUN_E2E='1'
dotnet test ./tests/OpenClaw.E2ETests/OpenClaw.E2ETests.csproj -c Debug -r win-x64 --filter "FullyQualifiedName~OpenClaw.E2ETests.Setup.SetupAndConnectTests" --logger "console;verbosity=normal"
  • Result: blocked before any setup-connect assertions ran. E2ESetupFixture.InitializeAsync() failed because the setup gateway could not become healthy due to EADDRINUSE on the randomly selected gateway port 59095 inside the local WSL distro:
Gateway failed to start: gateway already running under systemd; existing gateway did not become healthy after 30000ms | another gateway instance is already listening on ws://<host>:59095/ | listen EADDRINUSE: address already in use <ip>:59095 | EADDRINUSE
SetupPipeline: Step 'start-gateway' failed: Gateway did not become healthy within 90s

This is a local environment/gateway startup blocker, not a failure in the modified pending-approval cleanup path. CI setup-connect remains the required end-to-end proof for this PR.

Rubber-duck review

A rubber-duck review confirmed the root-cause direction: the reported failures do not create external trays themselves; they observe pending approval state leaked by earlier external-tray tests in the shared fixture. Review feedback led to two hardening changes in this PR: cleanup no longer masks the original scenario failure, and cleanup tracks already handled request IDs to avoid duplicate reject/approve races.

External tray setup-connect scenarios can leave delayed device/node approval requests behind in the shared gateway fixture. Later healthy-state assertions then see global pending requests and fail depending on test order/timing.

Snapshot pending approvals before each external tray scenario, dispose the external tray before cleanup, and reject only newly-created unhandled requests until the pending state stays quiet. Track requests already approved/rejected by the test body so cleanup does not double-decide them, and keep cleanup failures from masking the original scenario failure.

Co-authored-by: Copilot <[email protected]>
@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 9:32 PM ET / 01:32 UTC.

Summary
The PR updates SetupAndConnectTests so external tray setup scenarios dispose the extra tray, track handled approval IDs, and reject newly-created unhandled device/node approvals until the shared gateway stays quiet.

Reproducibility: no. high-confidence local reproduction was established in this review. The current-main source and PR body make the pending-approval leak path plausible, but the contributor's focused E2E attempt was blocked before assertions.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 1 E2E test file modified. The product blast radius is low, but the PR directly changes setup-connect validation behavior.
  • Diff size: 202 additions, 70 deletions. The cleanup is localized but non-trivial enough that real E2E proof matters before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post or link a redacted current-head setup-connect E2E log/artifact showing the pending approvals remain clear after the external-tray scenarios.
  • [P1] Let the in-progress setup-connect CI shard finish green before merge.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body includes validation and a blocked E2E log, but no positive current-head setup-connect proof; add a redacted passing log or artifact to the PR body, which should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The focused setup-connect E2E run in the PR body was blocked before any setup-connect assertions ran, so the cleanup loop has not yet been positively observed in the real gateway path.
  • [P1] The setup-connect CI check was still in progress when reviewed; merging before a passing shard or equivalent redacted runtime log risks keeping or reshaping the E2E flake.

Maintainer options:

  1. Wait for setup-connect proof (recommended)
    Require the in-progress setup-connect E2E shard or a redacted current-head terminal/log artifact to show the cleanup reaches a quiet pending-approval state before merge.
  2. Accept test-only risk
    Maintainers can choose to merge from source review and standard validation if they are willing to own possible continued setup-connect flake churn.

Next step before merge

  • [P1] Needs maintainer/contributor follow-up for positive setup-connect E2E proof; source review did not identify a narrow automated code repair.

Security
Cleared: The diff is limited to setup E2E test cleanup and does not change production secrets, permissions, dependencies, workflows, or command execution surfaces.

Review details

Best possible solution:

Land the focused cleanup after a positive current-head setup-connect E2E run or redacted runtime artifact shows pending approvals remain clear after the external-tray scenarios.

Do we have a high-confidence way to reproduce the issue?

No high-confidence local reproduction was established in this review. The current-main source and PR body make the pending-approval leak path plausible, but the contributor's focused E2E attempt was blocked before assertions.

Is this the best way to solve the issue?

Yes, pending proof: cleaning up newly-created pending approvals while preserving AssertNoPendingRequests is the narrow maintainable direction. The missing piece is a positive real setup-connect run showing the new cleanup actually quiets the shared gateway.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b4a8d49064a1.

Label changes

Label changes:

  • add P2: This is a normal-priority setup-connect E2E flake fix with limited product blast radius but real CI reliability impact.
  • add merge-risk: 🚨 automation: The diff changes E2E cleanup behavior and is not yet backed by a passing setup-connect run or equivalent positive runtime proof.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes validation and a blocked E2E log, but no positive current-head setup-connect proof; add a redacted passing log or artifact to the PR body, which should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a normal-priority setup-connect E2E flake fix with limited product blast radius but real CI reliability impact.
  • merge-risk: 🚨 automation: The diff changes E2E cleanup behavior and is not yet backed by a passing setup-connect run or equivalent positive runtime proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes validation and a blocked E2E log, but no positive current-head setup-connect proof; add a redacted passing log or artifact to the PR body, which should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

Likely related people:

  • bkudiess: The relevant setup-connect test file and IsolatedTrayInstance helper blame to commit a3c5e0b, authored by Barbara Kudiess and associated with the recent merged setup/gateway E2E work. (role: introduced current setup/gateway E2E surface; confidence: medium; commits: a3c5e0bf6fce; files: tests/OpenClaw.E2ETests/Setup/SetupAndConnectTests.cs, tests/OpenClaw.E2ETests/IsolatedTrayInstance.cs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jun 30, 2026
@shanselman
shanselman merged commit 84fcf8a into main Jun 30, 2026
21 checks passed
@shanselman
shanselman deleted the shanselman-fix-setup-e2e-flake branch June 30, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant