fix(msg): partition attachment bytes without temporary filesystem names
Summary
MSG attachments are already available as bytes from python-oxmsg, but the attachment partitioner writes each one to a newly created temporary directory and reopens it using its original name. This adds a filesystem write/read cycle for every attachment and can abort an otherwise readable message when the attachment name exceeds the worker filesystem's filename limit.
Pass the existing attachment bytes to partition() in a context-managed BytesIO, with the sanitized original name in metadata_filename. The MSG layer no longer needs a temporary directory or a local filename for the attachment. Format-specific conversion can still use its own temporary storage when needed.
Text, attachment names, MIME types, last-modified metadata, attachment markers, and the existing filename sanitizer are retained. The stream is closed after partitioning, including error paths.
Validation
- The real
fake-email-attachment.msgfixture reproduces failures with a 304-character ASCII name, a 124-character Chinese name that exceeds a 255-byte filename limit, and unavailable temporary storage. All three fail on unchangedmainand pass here. - Short filenames and path sanitization remain covered.
- Five integration comparisons pass real DOCX, PPTX, CSV, TSV, and XLSX fixture bytes through an MSG attachment and compare element types, text, table HTML, and MIME types with standalone partitioning.
- MSG suites: 76 passed, 1 deselected. The existing image/PDF inference attachment integration case requires optional dependencies unavailable in this environment; it fails on unchanged
mainfor that reason. - Full-repository Ruff lint and formatting pass.
git diff --checkpasses.- Full
make testhas not been run.
Validation follow-up
- The formal repository-wide
make checkcommand passes on this contribution's worktree. - The current CI workflow run is completed with
action_requiredand has started zero jobs. It supplies no CI test result yet. The fullmake testand coverage gates remain unverified and await hosted CI approval.
Checklist
- The PR title is a user-facing release-note entry with a conventional commit prefix.
- Apply the
bugcategory label; a maintainer may need to apply it. - No breaking API change. Attachments that previously worked preserve their document content and metadata.