Skip to content

fix(line): truncate action fields on code-point boundaries#97470

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
ly-wang19:fix/line-action-label-surrogate-safe
Jun 28, 2026
Merged

fix(line): truncate action fields on code-point boundaries#97470
vincentkoc merged 3 commits into
openclaw:mainfrom
ly-wang19:fix/line-action-label-surrogate-safe

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

What Problem This Solves

LINE action labels/data used raw UTF-16 slicing. When an emoji or other astral character landed on the LINE field limit boundary, the outgoing action payload could contain a dangling surrogate half.

Why This Change Was Made

The LINE action builders now use the existing plugin SDK truncateUtf16Safe helper for label/data/displayText fields while preserving the existing 20 and 300 code-unit limits.

User Impact

LINE actions with long labels or postback data containing emoji no longer produce malformed text at truncation boundaries.

Evidence

  • git diff --check origin/main...HEAD
  • node scripts/run-vitest.mjs extensions/line/src/message-cards.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main

Autoreview result: clean; no accepted/actionable findings.

After-fix Proof

Boundary probe on this PR branch:

{
  "usesSafeTruncate": true,
  "label": "1234567890123456789",
  "dataLength": 299,
  "labelHasLoneSurrogate": false,
  "dataHasLoneSurrogate": false
}

The probe places an emoji across the 20-unit LINE label limit and 300-unit postback data limit. Both are truncated without leaving a lone UTF-16 surrogate.

ly-wang19 and others added 2 commits June 24, 2026 20:37
The LINE action builders truncated label (20) and data/displayText (300)
with a raw `String.prototype.slice`, which cuts an emoji apart when the
limit falls inside a surrogate pair. A 19-char label followed by 😀
(U+1F600) yielded a label ending in a lone high surrogate (\uD83D), which
LINE renders as a replacement glyph or rejects.

Truncate with `truncateUtf16Safe` instead so a dangling half-emoji is
dropped, matching how this plugin already truncates LINE template titles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- drop the unnecessary template literal (no-unnecessary-template-expression)
- cast messageAction/uriAction results to { label: string } so loneHighSurrogate.test()
  receives a string (matches the postback/datetime test casts)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added channel: line Channel integration: line size: S labels Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 2:31 PM ET / 18:31 UTC.

Summary
This PR replaces raw UTF-16 slicing for LINE action label/data/displayText fields with the existing surrogate-safe SDK helper and adds regression coverage for action builders, card commands, Markdown link buttons, media-control buttons, and quick replies.

PR surface: Source +2, Tests +150. Total +152 across 8 files.

Reproducibility: yes. On current main, messageAction("1234567890123456789😀") and the 300-code-unit postback data/displayText cases follow raw .slice paths that can leave a dangling high surrogate; I did not run tests in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #97470
Summary: This PR is the active candidate for LINE action-field surrogate-safe truncation; prior same-author attempts are closed unmerged and the open template-text PR covers a neighboring surface.

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: 🐚 platinum hermit
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; no blocking finding remains and the next step is normal maintainer review plus required CI.

Security
Cleared: The diff reuses an existing SDK text helper and adds tests; it does not change dependencies, workflows, secrets, lockfiles, package metadata, or install/publish scripts.

Review details

Best possible solution:

Land this focused LINE action-field fix after required checks, while keeping the separate template title/altText cleanup in #97428.

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

Yes. On current main, messageAction("1234567890123456789😀") and the 300-code-unit postback data/displayText cases follow raw .slice paths that can leave a dangling high surrogate; I did not run tests in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing SDK text helper from LINE-owned action builders and routing sibling action-producing paths through that helper is the narrowest maintainable fix; the adjacent template title/altText work is separate.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 881ec2f93f37.

Label changes

Label justifications:

  • P2: This is a normal-priority LINE channel payload correctness fix with limited blast radius and no evidence of security, data-loss, or core availability impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes branch-specific boundary-probe live output showing no lone surrogate after truncating LINE label/data fields.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes branch-specific boundary-probe live output showing no lone surrogate after truncating LINE label/data fields.
Evidence reviewed

PR surface:

Source +2, Tests +150. Total +152 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 29 27 +2
Tests 3 150 0 +150
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 179 27 +152

What I checked:

  • Repository policy read: Root AGENTS.md and extensions/AGENTS.md were read fully; their full code-path review and extension-boundary guidance applied to this LINE plugin review. (AGENTS.md:1, 881ec2f93f37)
  • Current main bug path: Current main truncates LINE action builder labels and data with raw .slice(0, 20) / .slice(0, 300), which can cut between UTF-16 surrogate halves. (extensions/line/src/actions.ts:12, 881ec2f93f37)
  • Sibling action surfaces on main: Current main also has raw action-label/data truncation in card-command actions, Markdown link buttons, quick replies, and media-control postback buttons. (extensions/line/src/card-command.ts:65, 881ec2f93f37)
  • PR implementation: The PR head adds LINE action truncation helpers backed by truncateUtf16Safe and routes message, URI, postback, and datetime picker actions through them. (extensions/line/src/actions.ts:9, 3880ab113eef)
  • Sibling coverage in PR: The latest head routes /card parsed actions, Markdown link buttons, quick replies, and media-control action labels through the shared LINE action helper path. (extensions/line/src/card-command.ts:63, 3880ab113eef)
  • Helper contract: truncateUtf16Safe clamps the requested max length and delegates to sliceUtf16Safe, which backs off when the slice would end on a dangling high surrogate. (src/shared/utf16-slice.ts:35, 881ec2f93f37)

Likely related people:

  • steipete: Merged PR metadata for the original LINE plugin lists commits authored by steipete, and commit d71f6af introduced the centralized action helpers that currently contain the raw slice limits. (role: original code author and action-helper refactor author; confidence: high; commits: c96ffa7186a4, d71f6afb7f7b; files: src/line/actions.ts, src/line/template-messages.ts, extensions/line/src/actions.ts)
  • plum-dawg: feat: Add Line plugin #1630 was authored by plum-dawg and introduced the broader LINE plugin surfaces that later moved under extensions/line. (role: original LINE plugin proposer; confidence: medium; commits: c96ffa7186a4; files: extensions/line/src/card-command.ts, src/line/send.ts, src/line/markdown-to-line.ts)
  • vincentkoc: Commit 2131981 moved LINE channel ownership into extensions/line, and the latest PR head commit expands this branch to cover sibling LINE action surfaces. (role: recent area refactor and adjacent contributor; confidence: medium; commits: 213198123042, 3880ab113eef; files: extensions/line/src/actions.ts, extensions/line/src/send.ts, extensions/line/src/markdown-to-line.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.

@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 Jun 28, 2026
@vincentkoc
vincentkoc force-pushed the fix/line-action-label-surrogate-safe branch from a9eb4e5 to 3880ab1 Compare June 28, 2026 18:26
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer follow-up pushed to broaden the original fix before landing.

What changed:

  • Centralized LINE action label/data truncation helpers in extensions/line/src/actions.ts.
  • Routed /card actions, markdown link buttons, quick replies, and media-control postback labels through surrogate-safe truncation.
  • Added regression coverage for the sibling action surfaces that still had raw UTF-16 slicing.

Local proof on head 3880ab113e:

  • node scripts/run-vitest.mjs extensions/line/src/message-cards.test.ts extensions/line/src/markdown-to-line.test.ts extensions/line/src/send.test.ts -- --run
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo
  • ./node_modules/.bin/oxlint extensions/line/src/actions.ts extensions/line/src/card-command.ts extensions/line/src/flex-templates/media-control-cards.ts extensions/line/src/markdown-to-line.ts extensions/line/src/send.ts extensions/line/src/markdown-to-line.test.ts extensions/line/src/message-cards.test.ts extensions/line/src/send.test.ts
  • git diff --check

GitHub checks on head 3880ab113e: 58 successful, 0 failing, 0 pending. Merging now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: line Channel integration: line 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: M 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