Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/partition_signed_emails #3922

Open
anotherthomas opened this issue Feb 14, 2025 · 0 comments
Open

bug/partition_signed_emails #3922

anotherthomas opened this issue Feb 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@anotherthomas
Copy link

anotherthomas commented Feb 14, 2025

testcase.txt

Describe the bug
I'm trying to partition emails. In some cases, the processing results in a KeyError: 'multipart/mixed'

>>> from unstructured.partition.email import partition_email
>>> partition_email("testcase.txt")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/unstructured/partition/email.py", line 73, in partition_email
    return list(_EmailPartitioner.iter_elements(ctx=ctx))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/unstructured/partition/email.py", line 333, in _iter_elements
    yield from _AttachmentPartitioner.iter_elements(attachment, self._ctx)
  File "/app/unstructured/partition/email.py", line 388, in _iter_elements
    file = io.BytesIO(self._file_bytes)
                      ^^^^^^^^^^^^^^^^
  File "/app/unstructured/utils.py", line 154, in __get__
    value = self._fget(obj)
            ^^^^^^^^^^^^^^^
  File "/app/unstructured/partition/email.py", line 423, in _file_bytes
    content = self._attachment.get_content()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/email/message.py", line 1124, in get_content
    return content_manager.get_content(self, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/email/contentmanager.py", line 25, in get_content
    raise KeyError(content_type)
KeyError: 'multipart/mixed'

To Reproduce
The easiest way to reproduce the behavior for me is to try to partition a PGP signed but not encrypted email. I have attached an anonymized example.

Expected behavior
I expect the email to be parsed and partitioned into its parts.

Environment Info
docker image downloads.unstructured.io/unstructured-io/unstructured:0.16.20, also :0.15.14 and :latest

Additional context
Add any other context about the problem here.

@anotherthomas anotherthomas added the bug Something isn't working label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant