GeezerVison is showing github.com — fix(server): prevent lossy edits of non-UTF-8 workspace files by StiensWout · Pull Request #36545 · pingdotgg/t3code
Conversation
Editing a non-UTF-8 workspace file silently replaced invalid bytes with U+FFFD on the first autosave. Reject undecodable content through the existing binary-file error so the editor never receives lossy text. Valid UTF-8 and partial multibyte truncation keep their existing behavior. BOM preservation is separate and unchanged.
Small fast-lane fix: localized server validation, no new state, interface or UI flow.
Proof
The T3 Code bughunt found this, and Claude Opus 5.5 independently confirmed it on main d899bddfa2a6f824411eaae10fb7a8fa0a37bbb7.
- Red: the added invalid-UTF-8 row fails on that base because
readFile succeeds with caf�; the existing NUL case passes.
- Green:
pnpm exec vp test run apps/server/src/workspace/WorkspaceFileSystem.test.ts passes, including invalid input, valid UTF-8 and split multibyte truncation.
pnpm exec vp run check:changed passes. The trim run repeated both commands, and Sol independently reran the focused suite.
- Runtime decoder probe: valid café stays café; a standalone
e9 is rejected; streaming input ending in a partial character still drops that character.
- Rebased onto current main before filing;
git range-diff confirms the reviewed patch is unchanged.
scenarios:prove and real-client verification were not run. The service test reaches production decoding through real file I/O. Legacy-encoded files now use the existing unavailable/binary preview state instead of being editable. Mobile wording still calls them binary.
Local cubic: the unrelated VCS P1 was a stale-base comparison, resolved by rebasing with an unchanged patch. Its legacy-encoding preview nit is the intentional safety tradeoff. Opus's optional truncated-invalid-input test and mobile-copy nits remain open. No blocker or should findings remain. Shared client/server decoder consolidation is a follow-up.
Council review
| Reviewer |
Round 1 |
| Claude Opus 5.5 |
9/10 |
| GPT 6.1 Sol |
9.5/10 |
Small-PR council per Wout: two seats, no guest. Grok and guest tasks were cancelled when the instruction changed; neither gates this PR.
Closes #36544
Created with GPT 6.1 Sol (lead, bughunt and review) in the Codex harness and Claude Opus 5.5 (independent verification, build, trim and review) in the Claude harness, through T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
readFile decoded invalid UTF-8 into U+FFFD, so editing and saving such a
file silently replaced its original bytes. Decode fatally and reject the
file with the existing binary-file error; a multibyte character split by
the read limit is still dropped by streaming decode.
Co-authored-by: GPT 6.1 Sol <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Approvability
Verdict: Approved at 0abf0dc
Macroscope's review found this PR approvable — Invalid UTF-8 workspace files now use the existing binary-file error path instead of exposing lossy text for editing. The change leaves valid UTF-8 handling and file contents untouched while reducing accidental corruption risk.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
WorkspaceFileSystem.readFile now rejects invalid UTF-8 as a binary-file error, alongside files containing NUL bytes. Tests cover both cases. Truncated reads continue to use streaming decoding.
Changes: Workspace file read validation
| Layer / File(s) |
Summary |
Read validation and rejection tests apps/server/src/workspace/WorkspaceFileSystem.ts, apps/server/src/workspace/WorkspaceFileSystem.test.ts |
readFile uses fatal UTF-8 decoding and the shared WorkspaceBinaryFileError path for invalid UTF-8 and NUL-containing files. Tests cover both inputs and retain assertions that errors do not expose file contents. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: marcodotio, juliusmarminge
Merge Risk: Minimal · up to 6f3b0
-
Files with invalid UTF-8 now fail to open as binary instead of being shown with replacement characters that autosave could write back. Valid UTF-8 files and files truncated mid-character keep their existing behavior. No merge-blocking risk was found.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: the server now rejects non-UTF-8 workspace files so edits cannot lossily replace invalid bytes. It follows the conventional commit format and is specific enough for a … |
| Description check |
 |
The description covers the problem (silent U+FFFD replacement on autosave), the change (reject undecodable content via the existing binary-file error), and verification (focused test run, red/green ev… |
| Linked Issues check |
 |
Issue #36544 requires that editing an unsupported-encoding workspace file either preserves its original bytes or refuses the edit. The diff to apps/server/src/workspace/WorkspaceFileSystem.ts changes … |
| Out of Scope Changes check |
 |
All changed hunks serve the issue. The WorkspaceFileSystem.ts change adds fatal UTF-8 decoding and routes decode failures through the existing WorkspaceBinaryFileError. The binaryFileError helper avoi… |
Full details: Title check
-
Explanation
The title names the main change: the server now rejects non-UTF-8 workspace files so edits cannot lossily replace invalid bytes. It follows the conventional commit format and is specific enough for a teammate scanning history.
Full details: Description check
-
Explanation
The description covers the problem (silent U+FFFD replacement on autosave), the change (reject undecodable content via the existing binary-file error), and verification (focused test run, red/green evidence, runtime probe). It links issue #36544 under Scope and notes the author's council and model usage. The Scope section does not explain why a small fix needs no issue, but the issue is linked, so the gap is minor. The Verification section also lists what was not checked. Overall the description is mostly complete.
Full details: Linked Issues check
-
Explanation
Issue #36544 requires that editing an unsupported-encoding workspace file either preserves its original bytes or refuses the edit. The diff to apps/server/src/workspace/WorkspaceFileSystem.ts changes readFile to decode with new TextDecoder("utf-8", { fatal: true }). Invalid UTF-8 now fails inside Effect.try with catch: binaryFileError, which yields WorkspaceBinaryFileError. The file is therefore refused, and the server never returns replacement-character text that autosave could write back. The NUL-byte check is unchanged. Truncated reads keep stream: truncated, so a character split at the byte limit is still dropped. The test diff in WorkspaceFileSystem.test.ts adds an invalid-UTF-8 case (bytes 63 61 66 e9) to the binary-file rejection test, and it asserts the same WorkspaceBinaryFileError without content leakage. The issue requirement is a server-side coding requirement, and the code and test cover it. The PR does not preserve the original bytes. It refuses the edit, which the issue allows. I did not run the test suite. The result rests on the source diff and the PR's reported test results.
Full details: Out of Scope Changes check
-
Explanation
All changed hunks serve the issue. The WorkspaceFileSystem.ts change adds fatal UTF-8 decoding and routes decode failures through the existing WorkspaceBinaryFileError. The binaryFileError helper avoids duplicating that constructor for the NUL path and the decode path. The truncated-read comment and streaming behavior are kept. The test change parameterizes the existing binary-file test with a NUL case and an invalid-UTF-8 case. No unrelated files or behavior changes appear in the reviewed diff. The PR description states that BOM handling is unchanged, and the diff contains no BOM changes.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 99071c4 and 6f3b0c0.
Files selected for processing: 2
-
apps/server/src/workspace/WorkspaceFileSystem.test.ts
apps/server/src/workspace/WorkspaceFileSystem.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Evidence
Create notes.txt with Windows-1252 bytes 63 61 66 e9, open its project and thread, then select Files → notes.txt. If editable, append edited and await autosave. Inspect disk bytes on both sides.
Environment: real web client and server, Chromium 156 on Linux, 1280×800, light theme, fresh synthetic state and replay agent on each commit.
|
Before |
After |
| Commit |
99071c4953 |
6f3b0c043b |
| Result |
Editable caf�; autosave changed the original e9 into ef bf bd. Final bytes: 636166efbfbd20656469746564. |
No editor; unsupported UTF-8 notice. Original bytes remain 636166e9. |
| Open file |
 |
 |
| After edit attempt |
 |
 |
| Recording |
Before interaction |
After interaction |
Scenario source
scenarios:prove exited 0: fails on base and passes on head. Captures and recording frames were visually inspected.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
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.
|