Skip to content

Fix merge validation for blank translated chunks#18

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-1808
Draft

Fix merge validation for blank translated chunks#18
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-1808

Conversation

@cursor

@cursor cursor Bot commented Jun 7, 2026

Copy link
Copy Markdown

Bug and impact

  • A translated chunk containing only whitespace was treated as present/non-empty during merge validation.
  • merge_markdown_files() then stripped that chunk to empty content and skipped it, allowing output.md and final book artifacts to be generated with missing pages/chapters.
  • Severely truncated outputs were also only warnings, so a bad translation could still ship as a partial book.

Root cause

  • Validation used file byte size only and did not verify substantive text before merge.
  • The merge loop ignored empty content after .strip() instead of failing.
  • run_state could record blank/truncated outputs as usable state.

Fix

  • Reject blank/unreadable outputs and severely truncated outputs in manifest validation.
  • Fail manifest and legacy merges if a chunk trims to empty or cannot be read.
  • Mark blank/truncated outputs for re-translation and prevent recording them in run_state.
  • Added regression tests for manifest merge, legacy merge, and selective run-state planning/recording.

Validation

  • Reproduced the pre-fix bug: whitespace-only output_chunk0002.md produced merge_ok=True and an output.md missing chunk 2.
  • Verified post-fix reproduction now fails with ERROR: Blank output and does not create output.md.
  • python3 -m unittest tests.test_merge_and_build.MergeMarkdownValidationTests tests.test_run_state.RunStateTests -v
  • python3 -m unittest discover -s tests -p 'test_*.py' -v (210 tests, 3 skipped)
  • python3 -m compileall scripts tests
  • Full baseline smoke: converted standard-alice.epub, copied chunks as mock translations, merged and built HTML/DOCX/PDF successfully. EPUB still fails due to the documented Ubuntu Calibre 7.6.0 packaging bug.
Open in Web View Automation 

Co-authored-by: Rainman <deusyu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant