Skip to content

fix: report refused Gateway connections as network failures - #2029

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-handshake-flake-root-cause
Nov 6, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-handshake-flake-root-cause

Conversation

@bkudiess

@bkudiess bkudiess commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: refused Gateway connections are reported as server, rate-limit, or authentication failures when the local port happens to contain matching digits.

User Impact

User impact: refused Gateway connections are now reported as network failures, while TLS and HTTP upgrade failures retain their correct categories.

Why This Change Was Made

Transport classification now checks typed causes before message text and uses the same exception-aware classification for handshake observations and connection-failure events.

Evidence

The loopback refused-socket regression verifies both handshake and connection-failure events report Network. Deterministic exception-chain cases cover port-digit collisions, TLS socket resets, and HTTP status precedence. An independent rubber-duck review of the final diff found no actionable issues. The Windows interactive diagnostics proof pool was not run; see the proof limitation below.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: the corrected error category can appear in diagnostics; current-head UI proof was not run.

Validation

  • .\build.ps1 - passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --filter 'FullyQualifiedName~GatewayHandshakeObservationTests|FullyQualifiedName~GatewayErrorClassifierTests' - 73 passed, 0 failed, 0 skipped.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore - 4,936 passed, 25 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore - 5,062 passed, 0 skipped, 0 failed.

Real Behavior Proof

  • Environment tested: Windows x64, .NET SDK 10.0.403; Shared owner tests using a real loopback socket and deterministic exception chains. No app or live Gateway was launched.
  • PR head or commit tested: commit 11443f9830a4d943547693c7afb6d1f276ddbc6c; it contains the validated source. The test runner emitted no source receipt, so file SHA-256s were manually recorded at PR preparation: OpenClawGatewayClient.cs 77F7A7ECBD4A4E8B8049474E7AAD43F87356236FE5E252E7A86CEFFF46A539AC; GatewayHandshakeObservationTests.cs 50CAF948C66A0CAE944C70B8BC907184C2B91DAE39FF09A3D85D7D3E3CFA97D6.
  • Exact steps or command run: dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --filter 'FullyQualifiedName~GatewayHandshakeObservationTests|FullyQualifiedName~GatewayErrorClassifierTests'
  • Evidence after fix: 73 tests passed, including a refused connection to a bound, non-listening loopback port and deterministic cases for ports 55001, 54291, and 54011; TLS-reset and HTTP-status precedence cases also passed.
  • Observed result: handshake and connection-failure events report Network for refused transport; TLS remains Tls; HTTP 401, 429, and 503 remain Auth, RateLimited, and Server.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A.
  • Not verified or blocked: windows-winui-interactive was not run; no current-head visible UI diagnostics proof or live WSL Gateway proof was collected. Hosted CI results are tracked in the PR check list.

Security Impact

  • New permissions or capabilities? (Yes/No): No.
  • Secrets or tokens handling changed? (Yes/No): No.
  • New or changed network calls? (Yes/No): No.
  • Command or tool execution surface changed? (Yes/No): No.
  • Data access scope changed? (Yes/No): No.
  • If any answer is Yes, explain the risk and mitigation: N/A.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes; only incorrect failure categories are corrected.
  • Config or environment changes? (Yes/No): No.
  • Migration needed? (Yes/No): No.
  • If yes, list the exact upgrade steps: N/A.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codex review: ready, awaiting a maintainer decision.

What this changes

The PR classifies typed transport exceptions before message text and shares that classification between handshake observations and connection-failure events.

Example: A Gateway connection to ws://127.0.0.1:55001 is refused.

  • Before: The digits 500 in the port can produce the Server category.
  • After: The underlying SocketException produces Network in both failure events.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful production-client coverage, but evidence remains limited to in-process tests.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; supplied Windows evidence exercises the production client through a real refused loopback socket plus injected exception chains, while explicitly reporting that app diagnostics and live Gateway proof were not collected.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A refused Gateway connection can show server, rate-limit, or authentication failure guidance because its port contains matching digits.
Reason: The maintainer-authored direction restores defined transport classification while preserving TLS and HTTP categories without changing configuration or credential policy.

Merge readiness

⏳ Ready, awaiting maintainer decision

Keep open: this maintainer-authored PR repairs a source-confirmed defect still present on main, with no introduced correctness bug identified; its overlapping work needs coordination with #2023.

Priority: P2
Reviewed head: 11443f9830a4d943547693c7afb6d1f276ddbc6c
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Which PR should carry the overlapping exception-classification repair shared with fix: keep refused Gateway connections classified as network failures #2023?
  • Recommendation: Consolidate the repairs: Coordinate with the other author to retain this PR's event unification and TLS/HTTP precedence alongside the shared-text parsing repair in one landing path.
  • Why: Both PRs remain open with overlapping classifier hunks and distinct useful coverage, and no recorded discussion selects their landing relationship.

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped diagnostics transcript shows the corrected collision-port category, and this PR does not report a pre-fix failing run of its added regressions.
Agent review details

How this fits together

The shared operator Gateway client receives WebSocket exceptions and emits typed categories consumed by connection recovery and native setup diagnostics.

flowchart TD
  A[WebSocket connection attempt] --> B[Transport exception chain]
  B --> C[OpenClawGatewayClient classification]
  C --> D[Handshake observations]
  C --> E[Connection failure event]
  D --> F[Native setup diagnostics]
  E --> G[Gateway connection manager]
Loading

Technical review

Best possible solution:

Coordinate one landing path that retains typed exception precedence, consistent failure events, and the distinct shared-text parsing protection proposed by the overlapping PR.

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

Main deterministically matches 500 inside port 55001 before reaching the inner SocketException; source inspection establishes the path, but this read-only review executed no reproduction.

Is this the best way to solve the issue?

The patch is a focused existing-owner repair: typed causes must outrank incidental message digits, and both failure events should agree; every changed hunk supports those invariants without new state or parallel recovery machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4aee38a1bfaa.

Provenance checked

  • Handshake transport classification keeps the original intent (c43b7e9: Provide sanitized phase and failure diagnostics without exposing raw exceptions, credentials, or wire data.)
  • Connection-failure event classification keeps the original intent (bc210e0: Expose typed operator failures so recovery decisions distinguish transport problems from credential and listener failures.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit c43b7e9 adds src/OpenClaw.Shared/OpenClawGatewayClient.cs:246 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c43b7e9e7132; files: src/OpenClaw.Shared/OpenClawGatewayClient.cs)
  • Barbara Kudiess: Raw commit bc210e0 adds src/OpenClaw.Shared/OpenClawGatewayClient.cs:266 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc210e048aa9; files: src/OpenClaw.Shared/OpenClawGatewayClient.cs)

Preflight source

Source 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

Metric Value Why it matters
Production and regression coverage Production +33/-3 lines; tests +107/-0 lines Growth remains in existing owners and covers distinct classification precedence and event-consistency failures.

Labels

Label changes:

  • add P2: Incorrect categories mislead diagnostics and recovery guidance, without evidence that this defect itself prevents connections or changes credentials.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Label justifications:

  • P2: Incorrect categories mislead diagnostics and recovery guidance, without evidence that this defect itself prevents connections or changes credentials.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Optionally capture the corrected category through shipped diagnostics for a refused collision port, redacting credentials and non-public endpoints.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 5, 2026, 9:11 PM ET / November 6, 2026, 02:11 UTC.

@bkudiess bkudiess added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Nov 6, 2026
@bkudiess
bkudiess merged commit 4a833e4 into openclaw:main Nov 6, 2026
33 checks passed
@bkudiess bkudiess removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant