Skip to content

fix(parser): open macro-enabled Word packages as docx - #415

Merged
suguanYang merged 1 commit into
mainfrom
fix/suguan/docx-macro-enabled
Sep 14, 2026
Merged

suguanYang merged 1 commit into
mainfrom
fix/suguan/docx-macro-enabled

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

  • python-docx rejects OOXML packages whose main content type is .docm / .dotm / .dotx, even when the upload is named .docx. Production job_c63b2a825a93 failed this way (application/vnd.ms-word.document.macroEnabled.main+xml).
  • Rewrite that content type in-process before Document() / iter_block_items() / page estimation. Standard .docx bytes are returned unchanged.
  • Map macro-enabled and template Word MIME types to .docx for URL downloads.

Test plan

  • uv run pytest tests/unit/test_word_package.py in apps/worker
  • Reproduced the production ValueError on uploads/job_c63b2a825a93.docx, then confirmed parse (46 text blocks) and page estimation (4 pages, no fallback) succeed after the rewrite

Made with Cursor

python-docx rejects .docm content types even when the upload is named .docx. Rewrite the OOXML main content type in-process so parse and page estimation keep working without LibreOffice.

Co-authored-by: Cursor <cursoragent@cursor.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