Skip to content

fix(server): a large footnote no longer erases a DOCX attachment's body text - #48479

Open
StiensWout wants to merge 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-6b80fec2329a0615cdb883ae
Open

StiensWout wants to merge 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-6b80fec2329a0615cdb883ae

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

When a DOCX footnotes or endnotes part went over the XML node limit, extraction threw before reading any body paragraphs, so the saved text held only the truncation notice. The notes part is now read like the main document: the parser drops only the footnote or endnote still open at the limit, keeps every completed note inline where it is referenced, keeps the whole body, and ends the text with the truncation notice.

Related: #37889

Reproduction on main

Commit efbd62a7a7 (main). The extracted text contains only a truncation notice. The report body is missing. Expected: The extracted text retains the readable report body and marks the truncated material.

  1. Attach the sample DOCX with a short report and a large, heavily formatted footnote to a Replay (dev) thread.
  2. Send the attachment.
  3. Open the extracted text saved beside the attachment on the local server.

The cause is at apps/server/src/provider/documentTextWorker.ts:1890. Ran cd apps/server && pnpm exec vp test run src/provider/userInputAttachments.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with AssertionError: docx: Findings at a glance. in the output.

Evidence

Environment: Linux x64, the repository's own tests.

Proven: the repro fails at the test commit b8cb6f77d3 and passes on the head 8df0736c3c, both on main efbd62a7a7.

Before After
Commit b8cb6f77d3 8df0736c3c
Result failed with "AssertionError: docx: Findings at a glance." passed

Not shown: the bug in the running web app.

Tests

  • b8cb6f77d3 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed efbd62a7a700a29ad545f8334b2139407875dab3 passed on head.

Not in this change

  • A body part over the node limit still keeps only the text read before the limit, the same as before.
  • The other limits that stop extraction (output budget, archive and expanded-byte limits) are unchanged.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol

StiensWout and others added 3 commits December 3, 2026 23:12
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…dy text

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Dec 3, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 8df0736

Macroscope's review found this PR approvable — Oversized DOCX footnotes and endnotes no longer prevent extraction of the document body. Existing parsing limits and truncation signaling remain intact, keeping the change narrowly scoped.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DOCX extraction now reads footnote and endnote XML partially. It preserves available note content and reports XML node-limit truncation. New bounded extraction tests cover both note types.

Changes: DOCX note truncation

Layer / File(s) Summary
Partial note reading and truncation reporting
apps/server/src/provider/documentTextWorker.ts
The note-part loop uses readText and tracks whether a footnote or endnote tree was truncated. Incomplete note subtrees are dropped, and extraction throws Truncation("XML node limit") when either note part was truncated.
Bounded extraction tests
apps/server/src/provider/userInputAttachments.test.ts
Tests verify that bounded footnote extraction preserves main text and emits the truncation marker. A second test checks that extraction stops before processing a later endnote after reaching the limit.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: iamshadmantaqi, jadelike-wine

Merge Risk: Minimal · up to 8df07

DOCX files with very large footnote or endnote parts should now keep their body text and show a truncation notice. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: a large footnote no longer causes the DOCX attachment's body text to be erased. The raw summary confirms that footnotes and endnotes are now read with readText, so th…
Description check Passed The description follows the repository template. It covers the problem (a DOCX notes part over the XML node limit erased body text), the change (notes read like the main document, only the open note i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: a large footnote no longer causes the DOCX attachment's body text to be erased. The raw summary confirms that footnotes and endnotes are now read with readText, so the body is kept when a notes part hits the XML node limit. The title is specific, follows conventional commit form, and is about 76 characters, which is within a reasonable length.

Full details: Description check

Explanation

The description follows the repository template. It covers the problem (a DOCX notes part over the XML node limit erased body text), the change (notes read like the main document, only the open note is dropped, the truncation notice is kept), scope (links related issue #37889 and lists exclusions), and verification (a failing-then-passing repro test on specific commits, plus a check command). The Problem section gives a reproduction path and expected behavior. The Scope section does not clearly say why no issue is needed beyond the related link, but a related issue is linked, so this is a minor gap. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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 efbd62a and 8df0736.

Files selected for processing: 2

  • apps/server/src/provider/documentTextWorker.ts
  • apps/server/src/provider/userInputAttachments.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant