You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): RTF attachments that declare code page 0 or 866 reach the agent as text - #41340
When I attach an RTF file whose header declares \ansicpg0 or \ansicpg866 to a chat message, the agent gets no text from it. The server logs "Document text extraction failed." and writes no <id>.rtf.txt next to the attachment. Code page 0 is Windows' "system default ANSI code page" (CP_ACP), and 866 is the DOS Cyrillic code page. #41277 already made the web preview open these files; the server's attachment text extraction has its own code page check.
rtf() in apps/server/src/provider/documentTextWorker.ts accepts only \ansicpg874 and \ansicpg1250 to 1258 (plus 10000 for Macintosh) and throws "Unsupported RTF code page" for anything else, so the server stores the RTF file but produces no extracted text.
Change
rtf() now also accepts \ansicpg0, decoded as windows-1252 (the decoder it already uses when a file declares no code page), and \ansicpg866, decoded as ibm866. These are the same two mappings #41277 added to the web preview. Other code pages, such as \ansicpg99999 or \ansicpg932, are still rejected as before. The code page check now picks the decoder label first and rejects anything without one, so a bare \ansicpg with no number now fails with "Unsupported RTF code page" instead of an encoding error.
Scope
One problem in one server function, plus two rows in the existing RTF extraction test table. It needs no issue because it is a small fix for an obvious bug: a valid RTF attachment reaches the agent with no text. \fcharset handling is not changed.
Verification
An AI agent (T3 Code Nightly) ran each check below.
apps/server/src/provider/userInputAttachments.test.ts: two new rows in the "extracts RTF text" table check that {\rtf1\ansi\ansicpg0 Caf\'e9} extracts Café and that {\rtf1\ansi\ansicpg866 \'8f\'e0\'a8\'a2\'a5\'e2} extracts Привет. Both rows fail on 65cd6446233 with "Unsupported RTF code page"; on this branch all 49 tests pass. The existing checks that expect \ansicpg99999 and \ansicpg932 to be rejected still pass. vp run check:changed passes.
Real app on Linux, vp run dev --no-seed with a fresh empty home for each commit, no accounts needed.
Setup:
mkdir -p /tmp/rtf-repro
printf'%s''{\rtf1\ansi\ansicpg0 Hello world}'> /tmp/rtf-repro/cp0.rtf
printf'%s'"{\\rtf1\\ansi\\ansicpg866 \\'8f\\'e0\\'a8\\'a2\\'a5\\'e2}"> /tmp/rtf-repro/cp866.rtf
printf'%s''{\rtf1\ansi\ansicpg99999 Unsupported}'> /tmp/rtf-repro/cp99999.rtf
vp run dev --no-seed --home-dir "$(mktemp -d)"
Steps: on each commit, start the server as above → open the pairing URL → in the new thread, click Attach files → choose all three files in /tmp/rtf-repro → list the userdata/attachments/ folder under the baseDir that the [dev-runner] line prints, and read each <id>.rtf.txt.
File
65cd6446233 (before)
This branch
cp0.rtf
no .rtf.txt, "Document text extraction failed."
Hello world
cp866.rtf
no .rtf.txt, "Document text extraction failed."
Привет
cp99999.rtf
no .rtf.txt, "Document text extraction failed."
no .rtf.txt, "Document text extraction failed."
Before:
$ ls userdata/attachments/
pending-8e9daca5-…-rtf.rtf
pending-9f23bc9d-…-rtf.rtf
pending-b0d342bf-…-rtf.rtf
WARN: Document text extraction failed. { extension: 'rtf' } (3 times)
Not shown: macOS and Windows runs. The changed code has no platform branch, and windows-1252 and ibm866 are both standard WHATWG encoding labels. No screenshots, since nothing on screen changes; the evidence is the extracted text.
Reviewing files that changed from the base of the PR and between 1ac43c5 and 85bb5dd.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The RTF decoder now accepts code pages 0 and 866, mapping them to Windows-1252 and IBM866. Extraction tests cover escaped-byte decoding for both code pages.
Changes: RTF Code Page Support
Layer / File(s)
Summary
Decoder mapping and extraction tests apps/server/src/provider/documentTextWorker.ts, apps/server/src/provider/userInputAttachments.test.ts
Code page 0 maps to Windows-1252, and code page 866 maps to IBM866. Tests cover extraction of “Café” and “Привет” from escaped bytes.
RTF attachments declaring code page 0 or 866 will now be extracted as text instead of being rejected. Other unsupported code pages are still rejected. The change is small and tested, and no merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the change: RTF attachments declaring code page 0 or 866 now reach the agent as text. The summary, the code change in documentTextWorker.ts, and the two new test rows all match this. T…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each section has real content. The Problem section gives the bug and the expected behavior. The Chan…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the change: RTF attachments declaring code page 0 or 866 now reach the agent as text. The summary, the code change in documentTextWorker.ts, and the two new test rows all match this. The title uses the conventional commit form and is specific. It is 84 characters, a little over the usual short length, but still clear.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each section has real content. The Problem section gives the bug and the expected behavior. The Change section explains the code page mappings and the rejection behavior. The Scope section explains why the fix needs no linked issue. The Verification section gives focused test results, a before/after table, and the environments not checked (macOS and Windows). The author also names the model and harness, as the template asks. The description does not link an issue, but it gives a reason for that choice, which the template accepts.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Attached the same four RTF files through the real web composer on fresh databases; all uploads returned 204. Inspected the server-created text sidecars and displayed the observed results in the app terminal. Base loses code pages 0 and 866; head extracts Café and Привет. Supported 1252 and unsupported 99999 retain their behavior.
Scenario driver, with its temporary transcript destination made portable. Chromium, 1280×800, light theme on both sides. Recordings mask the temporary shell path during terminal startup; screenshots are unaltered. scenarios:prove exited 0.
Not shown:
A live provider consuming the extracted text was not exercised; proof covers the reported real upload and sidecar extraction failure.
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
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Problem
When I attach an RTF file whose header declares
\ansicpg0or\ansicpg866to a chat message, the agent gets no text from it. The server logs "Document text extraction failed." and writes no<id>.rtf.txtnext to the attachment. Code page 0 is Windows' "system default ANSI code page" (CP_ACP), and 866 is the DOS Cyrillic code page. #41277 already made the web preview open these files; the server's attachment text extraction has its own code page check.rtf()inapps/server/src/provider/documentTextWorker.tsaccepts only\ansicpg874and\ansicpg1250to1258(plus10000for Macintosh) and throws "Unsupported RTF code page" for anything else, so the server stores the RTF file but produces no extracted text.Change
rtf()now also accepts\ansicpg0, decoded aswindows-1252(the decoder it already uses when a file declares no code page), and\ansicpg866, decoded asibm866. These are the same two mappings #41277 added to the web preview. Other code pages, such as\ansicpg99999or\ansicpg932, are still rejected as before. The code page check now picks the decoder label first and rejects anything without one, so a bare\ansicpgwith no number now fails with "Unsupported RTF code page" instead of an encoding error.Scope
One problem in one server function, plus two rows in the existing RTF extraction test table. It needs no issue because it is a small fix for an obvious bug: a valid RTF attachment reaches the agent with no text.
\fcharsethandling is not changed.Verification
An AI agent (T3 Code Nightly) ran each check below.
apps/server/src/provider/userInputAttachments.test.ts: two new rows in the "extracts RTF text" table check that{\rtf1\ansi\ansicpg0 Caf\'e9}extractsCaféand that{\rtf1\ansi\ansicpg866 \'8f\'e0\'a8\'a2\'a5\'e2}extractsПривет. Both rows fail on65cd6446233with "Unsupported RTF code page"; on this branch all 49 tests pass. The existing checks that expect\ansicpg99999and\ansicpg932to be rejected still pass.vp run check:changedpasses.vp run dev --no-seedwith a fresh empty home for each commit, no accounts needed.Setup:
Steps: on each commit, start the server as above → open the pairing URL → in the new thread, click Attach files → choose all three files in
/tmp/rtf-repro→ list theuserdata/attachments/folder under thebaseDirthat the[dev-runner]line prints, and read each<id>.rtf.txt.65cd6446233(before)cp0.rtf.rtf.txt, "Document text extraction failed."Hello worldcp866.rtf.rtf.txt, "Document text extraction failed."Приветcp99999.rtf.rtf.txt, "Document text extraction failed.".rtf.txt, "Document text extraction failed."Before:
After:
Not shown: macOS and Windows runs. The changed code has no platform branch, and
windows-1252andibm866are both standard WHATWG encoding labels. No screenshots, since nothing on screen changes; the evidence is the extracted text.Generated with Gemini 4 Neon in T3 Code Nightly