Repository navigation
fix: keep refused Gateway connections classified as network failures - #2023
Conversation
Prefer typed transport causes over wrapper messages and prevent endpoint ports from being interpreted as HTTP status codes. Preserve genuine HTTP status classifications and add deterministic regressions without weakening the socket-level test. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe PR prevents endpoint-port digits and misleading exception wrappers from overriding network or TLS failure classifications. Example: A connection to ws://127.0.0.1:55030 is refused.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a source-confirmed defect still present on main, and inspection found no introduced correctness or security bug. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared Gateway client receives transport exceptions, emits sanitized handshake observations for native setup diagnostics, and uses the shared text classifier for connection recovery categories. flowchart TD
A[WebSocket transport failure] --> B[OpenClawGatewayClient]
B --> C[Typed exception inspection]
C --> D[Shared text classifier fallback]
B --> E[Connection failure event]
D --> F[Handshake observations]
F --> G[Native setup diagnostic log]
Technical reviewBest possible solution: Keep status-token parsing in GatewayErrorClassifier and typed-cause precedence in the existing observation classifier while preserving genuine HTTP classifications. Do we have a high-confidence way to reproduce the issue? Main deterministically matches 503 inside port 55030 and can return an outer Auth or Server message before inspecting an inner SocketException; the author reports matching before/after regression results, but this read-only review ran no tests. Is this the best way to solve the issue? This is a focused repair using the existing owners: endpoint digits must not become HTTP statuses, and typed transport causes must outrank wrapper wording; every changed hunk supports those invariants without adding state or a parallel recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4aee38a1bfaa. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 5, 2026, 4:50 PM ET / 21:50 UTC. |
Classify connection failures with the same typed transport logic as handshake observations. Preserve TLS classification for SecureConnectionError and cover both event paths. Co-authored-by: Copilot App <[email protected]>
Preserve mainline HTTP status classification while keeping typed transport causes authoritative over wrapper-message guesses. Co-authored-by: Copilot App <[email protected]>
What Problem This Solves
Fixes: refused Gateway connections can be reported as authentication, rate-limit or server failures when the endpoint port contains an HTTP-status-like digit sequence.
User Impact
User impact: failed transport observations report the actual network or TLS cause instead of a misleading wrapper message; endpoint port digits no longer drive authentication or server-error recovery categories.
No credential, permission, retry, timeout or configuration changes.
Why This Change Was Made
Scan the exception chain for typed socket, timeout and TLS causes before applying message heuristics. Match numeric status hints as standalone codes, excluding endpoint ports while retaining explicit HTTP/status syntax.
The existing socket-level regression stays unchanged. Genuine HTTP-status, authentication and TLS classifications remain covered. The separate
OnConnectionExceptionevent still uses its existing text-only classification; typed-cause precedence on that path remains a known follow-up outside this patch.Evidence
Before the production fix, 20 deterministic regressions failed: 10 endpoint-port cases, five wrapped endpoint cases, four misleading-wrapper socket/TLS cases and one timeout case. All 20 pass afterward. The final focused selection passes 457 tests, including the unchanged real loopback socket test.
Independent Copilot rubber-duck/source assessment found no blocking in-scope issue. It identified the unchanged
OnConnectionExceptionpath as an out-of-scope follow-up. Codex CLI was unavailable; the review used the advertisedrubber-duckrole, with model identity unverified and without helper-owned frozen-input/isolation guarantees. The author-side simplification pass retained the small existing-owner fix and distinct regression boundaries without further edits.This demonstrates the defect deterministically, but individual historical CI failures did not record ports or exception chains, so their attribution remains likely rather than proven.
Change Type
Scope
winnodeRequired proof pools
none: this patch changes pure error categorization and safe transport observations, not transport establishment, pairing, node invocation, UI rendering or runtime lifecycle. Deterministic Shared tests and the retained real loopback refusal test exercise the changed contract without a capacity-dependent custom host.Validation
Windows ARM64, Debug. Tests set
OPENCLAW_REPO_ROOTto the task worktree. Full-suite processes cleared inherited state/opt-in overrides, and Tray used session-owned settings storage.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --filter 'FullyQualifiedName~GatewayErrorClassifierTests|FullyQualifiedName~GatewayHandshakeObservationTests' --logger 'trx;LogFileName=classifier-before.trx' --results-directory .\TestResults\classifier-before --verbosity quiet: 84 passed, 20 failed, 0 skipped, 104 executed.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~GatewayErrorClassifierTests|FullyQualifiedName~GatewayHandshakeObservationTests|FullyQualifiedName~OpenClawGatewayClientTests' --logger 'trx;LogFileName=classifier-after-final.trx' --results-directory .\TestResults\classifier-after-final --verbosity quiet: 457 passed, 0 failed/skipped..\build.ps1: passed all five projects plus documentation validation, native ARM64 Debug.dotnet build .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --verbosity quiet: passed, 0 warnings/errors.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --logger 'trx;LogFileName=shared-final.trx' --results-directory .\TestResults\classifier-closeout-shared-final --verbosity quiet: 4,973 passed, 0 failed, 24 skipped, 4,997 total (2m48s). Skips: 17 opt-in device-identity integration cases and seven native MXC proof cases.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --logger 'trx;LogFileName=tray-final.trx' --results-directory .\TestResults\classifier-closeout-tray-final --verbosity quiet: 5,062 passed, 0 failed/skipped (1m38s).git --no-pager diff --check: passed.Real Behavior Proof
8550fa2b7080a16d827769af228e0979ebc141ee. Runs occurred before committing, on the unchanged four-file source now committed at this head, based on4aee38a1bfaa2f7d241130a3548d94f0547a3c9c; these are not post-commit reruns.Passed! - Failed: 0, Passed: 457, Skipped: 0, Total: 457. TRX comparison matched all original 20 failed test names to passing results afterward.Network; misleading outer messages do not override typed socket/timeout/TLS causes; genuine HTTP-status messages remain actionable.Yes/No/N/A): N/A. TRX files were checked locally; no public artifact links are claimed.OnConnectionExceptionevent path is not covered by this patch.Security Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations