Skip to content

fix(gateway-protocol): trim connect error detail codes in readConnectErrorDetailCode - #99555

Merged
steipete merged 3 commits into
openclaw:mainfrom
ly85206559:fix/connect-error-detail-code-trim
Jul 5, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
ly85206559:fix/connect-error-detail-code-trim

Conversation

@ly85206559

@ly85206559 ly85206559 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway connect-error payloads can carry padded details.code strings (leading/trailing whitespace). readConnectErrorDetailCode() previously returned the raw string after only checking code.trim().length > 0, so strict comparisons against ConnectErrorDetailCodes.* failed and downstream helpers (readPairingConnectErrorDetails, formatConnectErrorMessage) fell back to generic messages.

Why This Change Was Made

Return code.trim() from readConnectErrorDetailCode() so normalized detail codes match canonical constants and structured formatting paths run for untrusted gateway error details.

User Impact

Control UI and other gateway clients show correct pairing-required and protocol-mismatch messages when the server sends padded detail codes, instead of generic fallback text.

Evidence

  • Unit regressions in packages/gateway-protocol/src/connect-error-details.test.ts
  • Direct oxlint on touched gateway-protocol files
  • Standalone runtime proof against PR head 720115e02091e375b8b84be96842878dbe685458 showing padded detail codes normalize before pairing/protocol formatting

Real behavior proof

Standalone runtime proof

This runs outside Vitest and imports the PR-head gateway-protocol runtime module directly.

Command:

node --import tsx %TEMP%\openclaw-pr99555-proof.mjs

Output:

{
  "proof": "gateway connect-error detail code trim",
  "prHead": "720115e02091e375b8b84be96842878dbe685458",
  "pairing": {
    "rawCode": "  PAIRING_REQUIRED  ",
    "normalizedCode": "PAIRING_REQUIRED",
    "details": {
      "code": "PAIRING_REQUIRED",
      "reason": "role-upgrade",
      "requestId": "req_123",
      "remediationHint": "Review the requested role upgrade, then approve the pending request."
    },
    "formattedMessage": "role upgrade pending approval (requestId: req_123)"
  },
  "protocolMismatch": {
    "rawCode": "  PROTOCOL_MISMATCH  ",
    "normalizedCode": "PROTOCOL_MISMATCH",
    "formattedMessage": "protocol mismatch: Control UI v2-v4, Gateway v3, probe min v2"
  }
}

Rebase

git fetch origin
git rebase origin/main
# Successfully rebased (1/1); HEAD 2639cc666d4f9babd984f795d2317084da12fca1

Vitest

Command:

node scripts/run-vitest.mjs packages/gateway-protocol/src/connect-error-details.test.ts

Output:

RUN  v4.1.8 D:/WorkSpace/AI/openclaw-wt-connect-error-trim

Test Files  1 passed (1)
     Tests  17 passed (17)
  Duration  1.51s

[test] passed 1 Vitest shard in 16.68s

Oxlint

Command:

node_modules/.bin/oxlint packages/gateway-protocol/src/connect-error-details.ts packages/gateway-protocol/src/connect-error-details.test.ts

Output: no diagnostics; exit code 0.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 5:21 AM ET / 09:21 UTC.

Summary
This PR changes the gateway protocol connect-error detail reader to return trimmed non-empty detail codes and adds padded-code regression tests for the helper, pairing details, and protocol-mismatch formatting.

PR surface: Source 0, Tests +45. Total +45 across 2 files.

Reproducibility: yes. from source, without executing local tests in this read-only review. Current main and v2026.6.11 return raw padded detail codes while downstream gateway-client and Control UI paths compare those values strictly against canonical constants.

Review metrics: 1 noteworthy metric.

  • Shared reader normalization: 1 runtime return normalized; 3 padded-code regression paths added. The single runtime change affects every strict detail-code consumer, and the tests cover the helper plus downstream pairing and protocol formatting behavior.

Stored data model
Persistent data-model change detected: migration/backfill/repair: packages/gateway-protocol/src/connect-error-details.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Next step before merge

  • No ClawSweeper repair lane is needed; the PR has no actionable findings and awaits ordinary maintainer review and final mergeability checks.

Security
Cleared: No concrete security or supply-chain concern was found; the final diff changes a string normalizer and colocated tests only.

Review details

Best possible solution:

Land the shared-reader normalization with the focused regression tests after ordinary maintainer review; no new API, config, migration, or compatibility path is needed.

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

Yes from source, without executing local tests in this read-only review. Current main and v2026.6.11 return raw padded detail codes while downstream gateway-client and Control UI paths compare those values strictly against canonical constants.

Is this the best way to solve the issue?

Yes. Trimming in readConnectErrorDetailCode is the narrowest maintainable fix because downstream callers already route strict code comparisons through that shared untrusted-payload reader.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Sufficient terminal proof is present: the PR body includes copied standalone runtime output showing padded detail codes normalize into pairing and protocol formatting paths after the fix.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Sufficient terminal proof is present: the PR body includes copied standalone runtime output showing padded detail codes normalize into pairing and protocol formatting paths after the fix.

Label justifications:

  • P2: This is a normal-priority gateway/client bug fix for structured connect-error handling with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Sufficient terminal proof is present: the PR body includes copied standalone runtime output showing padded detail codes normalize into pairing and protocol formatting paths after the fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient terminal proof is present: the PR body includes copied standalone runtime output showing padded detail codes normalize into pairing and protocol formatting paths after the fix.
Evidence reviewed

PR surface:

Source 0, Tests +45. Total +45 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 45 0 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 46 1 +45

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the commit that introduced the original raw-return helper and also appears in current-line provenance for the helper in the present package path. (role: introduced behavior and recent area contributor; confidence: high; commits: bbdfba569440, d3641421a447; files: src/gateway/protocol/connect-error-details.ts, packages/gateway-protocol/src/connect-error-details.ts, ui/src/ui/gateway.ts)
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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-04T06:33:02.176Z sha 720115e02091e375b8b84be96842878dbe685458 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. scripts Repository scripts size: M labels Jul 3, 2026
@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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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. labels Jul 3, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with standalone runtime proof for padded gateway connect-error detail codes outside Vitest. The proof imports the PR-head gateway-protocol runtime module directly and shows both PAIRING_REQUIRED and PROTOCOL_MISMATCH padded codes normalize into the structured downstream formatting paths.

@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 3, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Labels were stripped at 15:36 UTC while the review comment still shows platinum hermit / proof sufficient. Please re-sync labels with the current review verdict.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 3, 2026
@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 4, 2026
@ly85206559
ly85206559 force-pushed the fix/connect-error-detail-code-trim branch from 720115e to ec9df84 Compare July 5, 2026 09:09
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@steipete steipete self-assigned this Jul 5, 2026
@steipete
steipete force-pushed the fix/connect-error-detail-code-trim branch from ec9df84 to 419f5c1 Compare July 5, 2026 23:47
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Maintainer fixup and land-ready verification complete on exact head 419f5c1da77d6d15d38f1222f4158104020b16ff.

  • Root cause confirmed: readConnectErrorDetailCode() used trim() to accept a non-empty untrusted code, then returned the raw padded value; canonical downstream comparisons therefore missed pairing, protocol, and recovery paths.
  • Best-fix verdict: normalize once in the shared gateway-protocol reader, rather than duplicating trimming in every client consumer.
  • Focused proof: sanitized AWS Crabbox cbx_1735d8b51466, run run_afce37954bc7; pnpm test packages/gateway-protocol/src/connect-error-details.test.ts passed 17/17.
  • Fresh AutoReview: clean, no accepted/actionable findings.
  • Exact-head hosted CI: https://github.com/openclaw/openclaw/actions/runs/28759084660 passed.
  • Native scripts/pr review artifacts and /prepare-pr gates passed. No known proof gaps.

Thank you @ly85206559 for the focused fix and regression coverage.

@steipete
steipete merged commit 5199f55 into openclaw:main Jul 5, 2026
96 checks passed
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@ly85206559
ly85206559 deleted the fix/connect-error-detail-code-trim branch July 6, 2026 07:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…ErrorDetailCode (openclaw#99555)

* fix(gateway-protocol): trim connect error detail codes in readConnectErrorDetailCode

Co-authored-by: Cursor <[email protected]>

* chore: add connect error detail code trim proof script

Co-authored-by: Cursor <[email protected]>

* chore(gateway-protocol): drop proof-only trim script

---------

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants