Skip to content

fix(email): fall back when the preferred MIME body is empty - #4821

Draft
Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/email-empty-body-fallback-20261121
Draft

Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/email-empty-body-fallback-20261121

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An email can contain both MIME alternatives while the preferred one is blank or contains only empty HTML markup. get_body() still selects that part, causing partitioning to return no body elements even when the other rendition contains the message.

When partitioning the preferred body produces no elements, try the other text rendition. Use the standard MIME body selector so attachments remain excluded. A usable preferred rendition is emitted once and does not trigger fallback.

Validation

  • Four real-email regressions fail on the base revision and pass after the fix; the nonempty-preference control passes throughout.
  • Covers blank/whitespace/markup-only HTML and an explicitly preferred empty plain-text alternative, retaining subject metadata.
  • Relevant email suite: 74 passed, 17 attachment cases deselected.
  • Full-repository Ruff 0.15.10 lint and format checks pass.

Draft pending the full repository test gate.

Checklist

  • Conventional user-facing title.
  • Maintainer: apply the bug label.
  • Full repository test gate.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant