Repository navigation
Commit fe1517d
committed
fix: partition_email raises KeyError on a multipart/* attachment
email.contentmanager has no get_content() handler registered for any
multipart/* content-type (handlers exist for text/*, application/*,
image/*, message/rfc822, etc., but multipart sub-parts are normally
consumed via .iter_parts(), not .get_content()). A multipart sub-part
can still surface as an "attachment" via iter_attachments() though --
e.g. a PGP/MIME-signed forwarded message (multipart/signed) nested
inside a multipart/mixed envelope, or a multipart/mixed forwarded
message itself. Resolving such an attachment's bytes in
_AttachmentPartitioner._file_bytes raised KeyError('multipart/signed')
(or 'multipart/mixed'), crashing the entire partition_email() call
instead of processing or skipping just that one attachment.
Fixed by falling back to the MIME part's raw serialized bytes
(as_bytes()) when its content-type is multipart/*, rather than calling
get_content(). This is a root-cause fix at the actual failure point,
not a broadening of the shared, deliberately narrow
EXPECTED_ATTACHMENT_ERRORS tuple (its own comment: "Intentionally
narrow... we do not catch RuntimeError... would otherwise be silently
skipped") -- a bare KeyError there would mask unrelated bugs elsewhere
in partition().
Fixes Unstructured-IO#3922.1 parent 114a1d5 commit fe1517d
4 files changed
Lines changed: 57 additions & 0 deletions
File tree
- example-docs/eml
- test_unstructured/partition
- unstructured/partition
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
392 | 408 | | |
393 | 409 | | |
394 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
435 | 445 | | |
436 | 446 | | |
437 | 447 | | |
| |||
0 commit comments