Skip to content

fix(discord): keep voice diagnostics bounded when ffmpeg errors are multibyte#104230

Merged
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-discord-ffmpeg-stderr-byte-cap
Jul 11, 2026
Merged

fix(discord): keep voice diagnostics bounded when ffmpeg errors are multibyte#104230
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-discord-ffmpeg-stderr-byte-cap

Conversation

@qingminglong

@qingminglong qingminglong commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users playing Discord voice audio could receive ffmpeg failure diagnostics that exceed the existing 8,192-byte cap when ffmpeg emits multibyte stderr text.

Why This Change Was Made

The Discord voice playback boundary now retains stderr as bytes and decodes the retained prefix safely after ffmpeg exits. This keeps the existing diagnostic cap accurate without changing playback, configuration, or channel behavior.

User Impact

Discord voice playback failures keep a bounded, readable ffmpeg diagnostic even when the underlying error text contains multibyte characters.

Evidence

  • Current head: 71fc6655daae1a2496fbc49159ecc544086222b6.
  • Claim proved: Discord voice ffmpeg failure diagnostics are capped at 8,192 raw stderr bytes and decoded without a replacement character when a multibyte UTF-8 sequence crosses the cap.
  • Real ffmpeg transcript: ffmpeg-win-x86_64-v7.1.exe -hide_banner -f lavfi -i anullsrc -filter_complex_script <utf8-filter-script> -f null - produced a failing ffmpeg child process with stderrByteLength: 24377, retainedBytes: 8192, decodedByteLength: 8191, replacementCount: 0, decodedEndsWithReplacement: false, and nonAsciiCount: 4004.
  • node scripts/run-vitest.mjs extensions/discord/src/voice/audio.test.ts — passed: 1 file, 7 tests.
  • node_modules\.bin\oxfmt.CMD --check --threads=1 extensions/discord/src/voice/audio.ts extensions/discord/src/voice/audio.test.ts — passed.
  • node_modules\.bin\oxlint.CMD extensions/discord/src/voice/audio.ts extensions/discord/src/voice/audio.test.ts — passed.
  • git diff --check upstream/main...HEAD — passed.
  • python .agents\skills\autoreview\scripts\autoreview --mode branch --base upstream/main — completed with no accepted or actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: XS labels Jul 11, 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. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

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

Summary
The PR retains at most 8,192 raw bytes of Discord voice ffmpeg stderr, decodes the complete UTF-8 prefix, and adds a multibyte-boundary regression test.

PR surface: Source +3, Tests +20. Total +23 across 2 files.

Reproducibility: yes. from current-main source with high confidence: the existing path truncates decoded string units rather than raw stderr bytes, so multibyte diagnostics can violate the stated byte limit. The regression test and direct Node decoder probe verify the relevant boundary behavior.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
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.

Next step before merge

  • No automated repair is needed; the PR is ready for ordinary maintainer merge review.

Security
Cleared: The two-file change only adjusts in-process stderr buffering and regression coverage, adding no dependency, permission, credential, network, installer, publishing, or downloaded-code surface.

Review details

Best possible solution:

Merge the plugin-local byte-buffer implementation and regression test so the existing diagnostic contract is enforced in raw bytes while always emitting valid UTF-8.

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

Yes, from current-main source with high confidence: the existing path truncates decoded string units rather than raw stderr bytes, so multibyte diagnostics can violate the stated byte limit. The regression test and direct Node decoder probe verify the relevant boundary behavior.

Is this the best way to solve the issue?

Yes. Bounding raw stderr at the owning ffmpeg child-process boundary is the narrowest maintainable fix, preserves existing playback and error propagation, and avoids introducing a second sanitization path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 107b95e1ad89.

Label changes

Label justifications:

  • P2: The PR fixes a real but limited Discord voice failure-diagnostic bug without changing successful playback, configuration, or channel routing.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The exact-head PR body provides after-fix output from a real failing ffmpeg process showing 24,377 stderr bytes bounded to 8,192 retained bytes and decoded without replacement characters.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head PR body provides after-fix output from a real failing ffmpeg process showing 24,377 stderr bytes bounded to 8,192 retained bytes and decoded without replacement characters.
Evidence reviewed

PR surface:

Source +3, Tests +20. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 6 +3
Tests 1 20 0 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 29 6 +23

What I checked:

  • Current-main defect: Current main decodes stderr to JavaScript strings and truncates by string length under the byte-named limit, allowing multibyte UTF-8 diagnostics to exceed 8,192 raw bytes. (extensions/discord/src/voice/audio.ts:119, 107b95e1ad89)
  • Exact-head implementation: The PR head replaces string slicing with a fixed 8,192-byte buffer and uses StringDecoder to omit an incomplete trailing UTF-8 sequence without producing U+FFFD. (extensions/discord/src/voice/audio.ts:112, 71fc6655daae)
  • Regression coverage: The added test splits a four-byte character at the cap and verifies the emitted diagnostic remains within the byte limit and contains no replacement character. (extensions/discord/src/voice/audio.test.ts:137, 71fc6655daae)
  • Real behavior proof: The updated PR body records an actual failing ffmpeg process producing 24,377 stderr bytes, with the patched path retaining 8,192 bytes and decoding a replacement-free multibyte diagnostic. (71fc6655daae)
  • Node decoder contract: A direct Node 24 StringDecoder probe with the same split boundary emitted only the complete UTF-8 prefix and no replacement character.
  • Owner boundary: Both streaming and file-based Discord voice playback call this plugin-owned ffmpeg stream helper, so the patch enforces the invariant at the single owning boundary. (extensions/discord/src/voice/segment.ts:174, 107b95e1ad89)

Likely related people:

  • vincentkoc: Git history and GitHub commit metadata attribute the current Discord voice playback helper, its callers, and the original stderr cap to this contributor's merged commit. (role: introduced current behavior; confidence: high; commits: ccab708c1633; files: extensions/discord/src/voice/audio.ts, extensions/discord/src/voice/segment.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-11T06:55:48.263Z sha 4bdf5b0 :: needs real behavior proof before merge. :: none

@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 11, 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.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 11, 2026
@steipete steipete self-assigned this Jul 11, 2026
@steipete
steipete merged commit 47751c1 into openclaw:main Jul 11, 2026
121 of 129 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

channel: discord Channel integration: discord P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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