Skip to content

fix(scripts): keep format-docs output tails UTF-8 safe - #110825

Merged
steipete merged 5 commits into
openclaw:mainfrom
wings1029:fix/format-docs-utf8-tail-safe
Jul 29, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
wings1029:fix/format-docs-utf8-tail-safe

Conversation

@wings1029

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where scripts/format-docs.mjs could render a replacement
character (�) in failure diagnostics when a formatter (oxfmt) error
output exceeded the 16 KiB tail cap and the byte window started inside a
multibyte UTF-8 character.

Why This Change Was Made

outputTail took a byte-bounded suffix with
bytes.subarray(-N).toString("utf8") before decoding. When the retained
byte window started at a UTF-8 continuation byte the tail began with a
replacement character. A new decodeUtf8Tail helper now skips any
leading continuation bytes, matching the existing pattern from the sibling
fix in scripts/run-additional-boundary-checks.mjs (#109167).

User Impact

Docs formatting failure diagnostics stay readable when capped output
contains multibyte text (e.g. oxfmt errors on CJK documentation pages) at
the retention boundary. No behaviour change for ASCII-only output.

Evidence

  • Before the fix, node -e confirmed that the last 4 bytes of
    Buffer.from("你好") (boundary at continuation byte 0xA0) produced a
    leading �.
  • After the fix, the same input produces "好" — the continuation byte
    is skipped and the intact character follows.
  • node scripts/run-vitest.mjs test/scripts/format-docs.test.ts -- -t decodeUtf8
    passed with 3 tests (continuation-byte skip, ASCII passthrough, empty
    buffer).
  • oxfmt --check passed on both changed files.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Jul 18, 2026
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 20, 2026, 8:34 AM ET / 12:34 UTC.

Summary
The PR extracts a shared outputTail helper that removes leading UTF-8 continuation bytes from byte-capped formatter diagnostics, then uses it in docs and generated-module formatting paths with regression coverage.

PR surface: Tests +45, Other 0. Total +45 across 6 files.

Reproducibility: yes. at source level: a UTF-8 string whose retained byte suffix begins on a continuation byte produces a replacement character in the pre-change decode path, and the supplied regression cases encode that exact boundary.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #110825
Summary: This PR is the broader canonical implementation for formatter diagnostic-tail UTF-8 safety: it includes the generated-module path from the overlapping open PR and the docs formatter path in one shared utility.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

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.

Risk before merge

  • [P1] The broad required-check set is still running on the current PR head, so merge should wait for those gates rather than treating the already-passed focused checks as the final merge signal.

Maintainer options:

  1. Decide the mitigation before merge
    Merge the shared helper after the current required checks complete successfully, then close the narrower overlapping generated-module-only PR as superseded by this integrated implementation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No actionable repair finding remains; the next action is routine maintainer review after the current required checks finish on this head.

Security
Cleared: The patch changes only local diagnostic-string handling and focused tests; it adds no dependency, workflow, secret, permission, download, or execution-surface change.

Review details

Best possible solution:

Merge the shared helper after the current required checks complete successfully, then close the narrower overlapping generated-module-only PR as superseded by this integrated implementation.

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

Yes, at source level: a UTF-8 string whose retained byte suffix begins on a continuation byte produces a replacement character in the pre-change decode path, and the supplied regression cases encode that exact boundary.

Is this the best way to solve the issue?

Yes. A shared helper is the narrowest maintainable fix because both formatter-output owners used the same unsafe byte-suffix decoding pattern; preserving each caller’s existing cap and message layout avoids a broader behavior change.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This corrects readability of capped formatter failure diagnostics without changing runtime product behavior, configuration, or delivery semantics.
  • 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): The PR body provides before/after terminal behavior for the split multibyte boundary and identifies the post-fix readable result, with focused regression tests covering direct and integrated formatter diagnostics.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides before/after terminal behavior for the split multibyte boundary and identifies the post-fix readable result, with focused regression tests covering direct and integrated formatter diagnostics.
Evidence reviewed

PR surface:

Tests +45, Other 0. Total +45 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 45 0 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 38 38 0
Total 6 83 38 +45

What I checked:

  • Shared implementation: The PR-head helper trims supported output, retains the configured byte suffix, discards only leading UTF-8 continuation bytes, then decodes the intact suffix; both affected formatter diagnostic paths now call it with their existing 16 KiB limits. (scripts/lib/output-tail.mjs:14, 369d2e89f995)
  • Both production callers migrate: format-docs and format-generated-module replace their local tail implementations with the shared helper without changing their caller-specific failure-message construction or byte budgets. (scripts/format-docs.mjs:49, 369d2e89f995)
  • Boundary regression coverage: The new tests construct a retained suffix beginning at a UTF-8 continuation byte and assert the readable 好 prefix with no replacement character in both direct helper and generated-module failure-message paths. (test/scripts/format-generated-module.test.ts:118, 369d2e89f995)
  • Established sibling precedent: Merged PR fix(ci): keep boundary output tails UTF-8 safe #109167 previously repaired the same byte-tail decoding failure mode in the additional-boundary-check script; this PR applies the same invariant to the two formatter-output owners. (scripts/run-additional-boundary-checks.mjs, f3e8164e7c0b)
  • Current PR state: The supplied PR state reports the head as cleanly mergeable; security and focused fast checks have passed, while the broader required-check set remains in progress on the current head. (369d2e89f995)

Likely related people:

  • steipete: Authored the current PR-head refactor that establishes the shared diagnostic-tail utility and migrates both formatter consumers. (role: recent refactor contributor; confidence: high; commits: 369d2e89f995; files: scripts/lib/output-tail.mjs, scripts/format-docs.mjs, scripts/lib/format-generated-module.mjs)
  • qingminglong: Authored the earlier merged sibling work that established the UTF-8-safe bounded-output pattern for another script-owned diagnostics path. (role: feature-pattern introducer; confidence: medium; commits: d51ef7829e08, f3e8164e7c0b; files: scripts/run-additional-boundary-checks.mjs, test/scripts/run-additional-boundary-checks.test.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 (7 earlier review cycles)
  • reviewed 2026-07-18T16:56:06.011Z sha ca043180b526d2ee0cb6bcf67d0f22608c7c0ce0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T17:31:42.966Z sha d5e5b6fe83a989560316668ad23654b4df6c8ad1 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T17:43:38.262Z sha b69f17f5e3523c59975ad2e67f55d029d7fa5629 :: needs changes before merge. :: [P2] Decode the declared Uint8Array input rather than Buffer-only values
  • reviewed 2026-07-19T04:49:26.898Z sha d6412a4f4e5ff60e09447f3d6cb896ca34c73cb7 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T04:57:29.751Z sha ea61001cf99499a685c6b30997b8b276894c7a2e :: needs changes before merge. :: [P2] Exercise a real UTF-8 continuation-byte boundary
  • reviewed 2026-07-19T05:25:54.169Z sha 538c94566ebb4065e0b88940b3e06dcf96055473 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T14:06:30.569Z sha d6f6ff0ccff81b8c13bf413b180b7db21d221644 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 18, 2026
@wings1029
wings1029 force-pushed the fix/format-docs-utf8-tail-safe branch 3 times, most recently from 84a480b to d6412a4 Compare July 19, 2026 04:45
@clawsweeper clawsweeper Bot added 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 19, 2026
@wings1029
wings1029 force-pushed the fix/format-docs-utf8-tail-safe branch from d6412a4 to ea61001 Compare July 19, 2026 04:53
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 19, 2026
@wings1029
wings1029 force-pushed the fix/format-docs-utf8-tail-safe branch from ea61001 to 538c945 Compare July 19, 2026 05:22
@clawsweeper clawsweeper Bot added 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 19, 2026
@wings1029
wings1029 force-pushed the fix/format-docs-utf8-tail-safe branch from 538c945 to d6f6ff0 Compare July 19, 2026 14:02
wings1029 and others added 2 commits July 20, 2026 05:22
When formatter (oxfmt) error output exceeds the 16 KiB tail cap and the
retained byte window starts inside a multibyte UTF-8 character, the
diagnostic tail would begin with a replacement character (�).

Add a decodeUtf8Tail helper that skips leading UTF-8 continuation bytes
before decoding the byte suffix, matching the existing pattern in
scripts/run-additional-boundary-checks.mjs (openclaw#109167).

Keep the existing 16 KiB cap and ASCII behavior unchanged.
@steipete
steipete force-pushed the fix/format-docs-utf8-tail-safe branch from d6f6ff0 to 369d2e8 Compare July 20, 2026 12:29
@steipete
steipete merged commit 796ee27 into openclaw:main Jul 29, 2026
167 of 169 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 29, 2026
* origin/main: (128 commits)
  fix(codex): keep stressed inference turns isolated and observable (#115893)
  feat(skills): review interrupted deep turns in experience review (#115887)
  fix: reject malformed UTF-8 in proxy gateway error response bodies (#111852)
  fix(browser): stabilize atomic download staging (#115892)
  fix(google): cancel unread response body on video download error (#110045)
  refactor(ui): give Memory the shared hub header with hoisted agent scope (#115884)
  fix(test): stop asserting exact video deadline budgets (#115883)
  feat(gateway): expose MCP tool identity in effective tools (#115870)
  fix(skills): verify workshop migration without recovery
  refactor: replace context-engine retry proxy with declared params (#115872)
  fix: reject malformed UTF-8 in hosted official plugin catalog feed responses (#111768)
  fix(codex): harden app inventory invalidation and targeted publishes (#115866)
  fix(browser): uploads fail when the browser runs on a remote node (#115291)
  fix(scripts): keep format-docs output tails UTF-8 safe (#110825)
  fix(skills): recover complete apply transitions
  fix(macos): reap timed-out shell process groups (#115859)
  refactor(ollama): unify model inspection and setup (#115879)
  fix(ui): muted theme text below WCAG AA contrast in webchat (#114586)
  fix(test): restore isolated memory manager tests (#115880)
  fix(skills): revalidate rollback targets
  ...
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…discovery

* origin/main: (72 commits)
  fix(codex): keep stressed inference turns isolated and observable (#115893)
  feat(skills): review interrupted deep turns in experience review (#115887)
  fix: reject malformed UTF-8 in proxy gateway error response bodies (#111852)
  fix(browser): stabilize atomic download staging (#115892)
  fix(google): cancel unread response body on video download error (#110045)
  refactor(ui): give Memory the shared hub header with hoisted agent scope (#115884)
  fix(test): stop asserting exact video deadline budgets (#115883)
  feat(gateway): expose MCP tool identity in effective tools (#115870)
  fix(skills): verify workshop migration without recovery
  refactor: replace context-engine retry proxy with declared params (#115872)
  fix: reject malformed UTF-8 in hosted official plugin catalog feed responses (#111768)
  fix(codex): harden app inventory invalidation and targeted publishes (#115866)
  fix(browser): uploads fail when the browser runs on a remote node (#115291)
  fix(scripts): keep format-docs output tails UTF-8 safe (#110825)
  fix(skills): recover complete apply transitions
  fix(macos): reap timed-out shell process groups (#115859)
  refactor(ollama): unify model inspection and setup (#115879)
  fix(ui): muted theme text below WCAG AA contrast in webchat (#114586)
  fix(test): restore isolated memory manager tests (#115880)
  fix(skills): revalidate rollback targets
  ...
vincentkoc added a commit that referenced this pull request Jul 29, 2026
* origin/main: (95 commits)
  fix(codex): keep stressed inference turns isolated and observable (#115893)
  feat(skills): review interrupted deep turns in experience review (#115887)
  fix: reject malformed UTF-8 in proxy gateway error response bodies (#111852)
  fix(browser): stabilize atomic download staging (#115892)
  fix(google): cancel unread response body on video download error (#110045)
  refactor(ui): give Memory the shared hub header with hoisted agent scope (#115884)
  fix(test): stop asserting exact video deadline budgets (#115883)
  feat(gateway): expose MCP tool identity in effective tools (#115870)
  fix(skills): verify workshop migration without recovery
  refactor: replace context-engine retry proxy with declared params (#115872)
  fix: reject malformed UTF-8 in hosted official plugin catalog feed responses (#111768)
  fix(codex): harden app inventory invalidation and targeted publishes (#115866)
  fix(browser): uploads fail when the browser runs on a remote node (#115291)
  fix(scripts): keep format-docs output tails UTF-8 safe (#110825)
  fix(skills): recover complete apply transitions
  fix(macos): reap timed-out shell process groups (#115859)
  refactor(ollama): unify model inspection and setup (#115879)
  fix(ui): muted theme text below WCAG AA contrast in webchat (#114586)
  fix(test): restore isolated memory manager tests (#115880)
  fix(skills): revalidate rollback targets
  ...
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…d-fingerprint

* origin/main: (36 commits)
  fix(codex): keep stressed inference turns isolated and observable (#115893)
  feat(skills): review interrupted deep turns in experience review (#115887)
  fix: reject malformed UTF-8 in proxy gateway error response bodies (#111852)
  fix(browser): stabilize atomic download staging (#115892)
  fix(google): cancel unread response body on video download error (#110045)
  refactor(ui): give Memory the shared hub header with hoisted agent scope (#115884)
  fix(test): stop asserting exact video deadline budgets (#115883)
  feat(gateway): expose MCP tool identity in effective tools (#115870)
  fix(skills): verify workshop migration without recovery
  refactor: replace context-engine retry proxy with declared params (#115872)
  fix: reject malformed UTF-8 in hosted official plugin catalog feed responses (#111768)
  fix(codex): harden app inventory invalidation and targeted publishes (#115866)
  fix(browser): uploads fail when the browser runs on a remote node (#115291)
  fix(scripts): keep format-docs output tails UTF-8 safe (#110825)
  fix(skills): recover complete apply transitions
  fix(macos): reap timed-out shell process groups (#115859)
  refactor(ollama): unify model inspection and setup (#115879)
  fix(ui): muted theme text below WCAG AA contrast in webchat (#114586)
  fix(test): restore isolated memory manager tests (#115880)
  fix(skills): revalidate rollback targets
  ...
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…ocess-probes

* origin/main: (56 commits)
  fix(codex): keep stressed inference turns isolated and observable (#115893)
  feat(skills): review interrupted deep turns in experience review (#115887)
  fix: reject malformed UTF-8 in proxy gateway error response bodies (#111852)
  fix(browser): stabilize atomic download staging (#115892)
  fix(google): cancel unread response body on video download error (#110045)
  refactor(ui): give Memory the shared hub header with hoisted agent scope (#115884)
  fix(test): stop asserting exact video deadline budgets (#115883)
  feat(gateway): expose MCP tool identity in effective tools (#115870)
  fix(skills): verify workshop migration without recovery
  refactor: replace context-engine retry proxy with declared params (#115872)
  fix: reject malformed UTF-8 in hosted official plugin catalog feed responses (#111768)
  fix(codex): harden app inventory invalidation and targeted publishes (#115866)
  fix(browser): uploads fail when the browser runs on a remote node (#115291)
  fix(scripts): keep format-docs output tails UTF-8 safe (#110825)
  fix(skills): recover complete apply transitions
  fix(macos): reap timed-out shell process groups (#115859)
  refactor(ollama): unify model inspection and setup (#115879)
  fix(ui): muted theme text below WCAG AA contrast in webchat (#114586)
  fix(test): restore isolated memory manager tests (#115880)
  fix(skills): revalidate rollback targets
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* fix(scripts): keep format-docs output tails UTF-8 safe

When formatter (oxfmt) error output exceeds the 16 KiB tail cap and the
retained byte window starts inside a multibyte UTF-8 character, the
diagnostic tail would begin with a replacement character (�).

Add a decodeUtf8Tail helper that skips leading UTF-8 continuation bytes
before decoding the byte suffix, matching the existing pattern in
scripts/run-additional-boundary-checks.mjs (openclaw#109167).

Keep the existing 16 KiB cap and ASCII behavior unchanged.

* refactor(scripts): share UTF-8-safe output tails

Co-authored-by: 陈志强0668000989 <[email protected]>

* test(scripts): prove real formatter UTF-8 failures

---------

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

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S 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