fix(msg): partition attachment bytes without temporary filesystem names

AF
9h ago
+100-8

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.msg fixture 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 unchanged main and 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 main for that reason.
  • Full-repository Ruff lint and formatting pass.
  • git diff --check passes.
  • Full make test has not been run.

Validation follow-up

  • The formal repository-wide make check command passes on this contribution's worktree.
  • The current CI workflow run is completed with action_required and has started zero jobs. It supplies no CI test result yet. The full make test and 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 bug category label; a maintainer may need to apply it.
  • No breaking API change. Attachments that previously worked preserve their document content and metadata.