Skip to content

fix: keep refused Gateway connections classified as network failures - #2023

Merged
karkarl merged 3 commits into
openclaw:mainfrom
karkarl:karkarl-handshake-classifier-flake-fix
Nov 6, 2026
Merged

karkarl merged 3 commits into
openclaw:mainfrom
karkarl:karkarl-handshake-classifier-flake-fix

Conversation

@karkarl

@karkarl karkarl commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

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 OnConnectionException event 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 OnConnectionException path as an out-of-scope follow-up. Codex CLI was unavailable; the review used the advertised rubber-duck role, 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

  • 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

  • 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_ROOT to the task worktree. Full-suite processes cleared inherited state/opt-in overrides, and Tray used session-owned settings storage.

  • Pre-fix: 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.
  • Final focused: 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.
  • Fresh Tray project bootstrap: 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

  • Environment tested: native Windows ARM64, .NET SDK 10.0.403, Debug; isolated test data.
  • PR head or commit tested: 8550fa2b7080a16d827769af228e0979ebc141ee. Runs occurred before committing, on the unchanged four-file source now committed at this head, based on 4aee38a1bfaa2f7d241130a3548d94f0547a3c9c; these are not post-commit reruns.
  • Exact steps or command run: final focused Shared command listed above.
  • Evidence after fix: copied runner output: Passed! - Failed: 0, Passed: 457, Skipped: 0, Total: 457. TRX comparison matched all original 20 failed test names to passing results afterward.
  • Observed result: refused loopback transport reports Network; misleading outer messages do not override typed socket/timeout/TLS causes; genuine HTTP-status messages remain actionable.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A. TRX files were checked locally; no public artifact links are claimed.
  • Not verified or blocked: live Gateway, UI, WSL/MXC, packaging and remote-host behavior were not launched or claimed. Required hosted CI is pending. Typed-cause precedence on the unchanged OnConnectionException event path is not covered by this patch.

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
  • 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.

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]>
@clawsweeper

clawsweeper Bot commented Nov 5, 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

The 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.

  • Before: The classifier reads 503 inside the port and returns Server.
  • After: The classifier excludes the port digits and returns Network.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified defect, but test-run output does not satisfy the required real-behavior proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
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 endpoint can produce misleading authentication, rate-limit or server-failure guidance because its port resembles an HTTP status.
Reason: The maintainer-authored direction repairs defined classification behavior with a narrow shared-owner change and preserves the disclosed, unchanged text-only event boundary.

Regression provenance

Possible 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
Reviewed head: 8550fa2b7080a16d827769af228e0979ebc141ee

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped application or diagnostic entry-point transcript demonstrates the corrected category for a refused endpoint whose port contains 503.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Numeric error classification keeps the original intent (f51a861: Provide specific recovery guidance for transport, authentication, pairing and server failures.)
  • Transport observation exception classification keeps the original intent (c43b7e9: Emit sanitized handshake diagnostic categories without scanning stack frames or changing connection recovery policy.)

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 f51a861 adds src/OpenClaw.Shared/GatewayErrorClassifier.cs:69 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f51a8618ed7b; files: src/OpenClaw.Shared/GatewayErrorClassifier.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 +15/-4 lines; tests +112/-0 lines Growth stays within existing owners and covers distinct parsing, exception-chain and HTTP-preservation boundaries.

Labels

Label changes:

  • add P2: Misclassification produces misleading diagnostics and recovery categories, with no demonstrated loss of availability or credentials.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Misclassification produces misleading diagnostics and recovery categories, with no demonstrated loss of availability or credentials.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Capture the corrected failure category through the shipped diagnostics path, 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, 4:50 PM ET / 21:50 UTC.

karkarl and others added 2 commits November 6, 2026 10:08
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]>
@karkarl
karkarl merged commit c4269f5 into openclaw:main Nov 6, 2026
25 checks passed
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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant