fix: use Vec<u8> for exec stdout/stderr to prevent UTF-8 corruption#361
Open
yan5xu wants to merge 3 commits intoboxlite-ai:mainfrom
Open
fix: use Vec<u8> for exec stdout/stderr to prevent UTF-8 corruption#361yan5xu wants to merge 3 commits intoboxlite-ai:mainfrom
yan5xu wants to merge 3 commits intoboxlite-ai:mainfrom
Conversation
Holds a single BoxliteRuntime and exposes box lifecycle + exec operations
over HTTP. Solves runtime lock contention when multiple callers need
concurrent access (e.g. Pinix Server executing nested clip-to-clip calls).
Endpoints (9, MVP):
- GET /v1/config
- POST /v1/local/boxes (create)
- GET /v1/local/boxes (list)
- GET /v1/local/boxes/{id} (info)
- POST /v1/local/boxes/{id}/start
- POST /v1/local/boxes/{id}/stop
- POST /v1/local/boxes/{id}/exec (returns execution_id, supports stdin)
- GET /v1/local/boxes/{id}/executions/{eid}/output (SSE stream)
- DELETE /v1/local/boxes/{id}
SSE exec protocol:
event: stdout, data: {"data":"<base64>"}
event: stderr, data: {"data":"<base64>"}
event: exit, data: {"exit_code":0,"duration_ms":1234}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three fixes for BoxLite serve mode:
1. serve: add volumes field to CreateBoxRequest and pass to BoxOptions
- Without this, virtiofs mounts were silently dropped and /clip
was not visible inside containers
2. disk/ext4: quote host path in debugfs write command
- Paths containing spaces (macOS "Application Support") caused
debugfs to silently fail, leaving guest binary missing from rootfs
3. guest: mount devtmpfs at /dev for block device node auto-creation
- Kernel sees block devices in /proc/partitions but /dev/vd* nodes
were missing, preventing Container.Init from mounting disks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
String::from_utf8_lossy() was replacing incomplete UTF-8 sequences at gRPC chunk boundaries with U+FFFD replacement characters. Changed stdout/stderr channels from String to Vec<u8> throughout: - portal/interfaces/exec.rs: route_output sends raw bytes - litebox/exec.rs: ExecStdout/ExecStderr yield Vec<u8> - serve.rs: base64-encodes raw bytes directly - terminal/mod.rs: writes raw bytes to stdout/stderr Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
String::from_utf8_lossy()inportal/interfaces/exec.rswas replacing incomplete UTF-8 byte sequences at gRPC chunk boundaries with U+FFFD replacement charactersStringtoVec<u8>throughout the pipeline to preserve raw bytesChanges
portal/interfaces/exec.rs:route_outputsends rawchunk.data(Vec) instead ofString::from_utf8_lossyconversionlitebox/exec.rs:ExecStdout/ExecStderrstream items changed fromStringtoVec<u8>serve.rs: base64-encodes raw bytes directly (was.as_bytes()on String)terminal/mod.rs: writes raw bytes to stdout/stderr (was.as_bytes()on String)Root cause analysis
Verified: same Go binary producing 130KB JSON output had 6 U+FFFD in DB (pre-existing) but 11 after passing through BoxLite serve — the extra 5 were introduced by
from_utf8_lossy.Test plan
cargo build --release -p boxlite-clipassespinix invoke get-topicnow returns exactly 6 U+FFFD (matching DB), down from 11🤖 Generated with Claude Code