bug: partition_email() raises io.UnsupportedOperation on a file-like object that cannot seek
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Leggi unstructured/partition/email.py, in particolare EmailPartitioningContext._validate() e la proprietà msg, poi confronta come partition_json() e partition_ndjson() gestiscono i flussi non riposizionabili, come descritto in #4643 e #4649. Riproduci il problema con una pipe leggibile o un altro oggetto simile a un file non riposizionabile e confrontane l'output con quello di io.BytesIO contenente gli stessi byte dell'email. Il lavoro è completato quando partition_email(file=...) restituisce gli stessi elementi per entrambi gli input.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
partition_email(file=...) raises io.UnsupportedOperation: File or stream is not seekable. when the file-like object is readable but cannot seek back, such as the read end of a pipe. An unbuffered handle (open(fd, "rb", buffering=0)) fails the same way with OSError: [Errno 29] Illegal seek.
EmailPartitioningContext._validate() rewinds file unconditionally with self._file.seek(0) (unstructured/partition/email.py), before the message is parsed. The partitioner reads the message once after that (self._file.read() in the msg property), so the rewind is the only thing such a stream cannot provide.
The sibling partitioners accept the same kind of stream when called directly: partition_text(), partition_html() and partition_xml() read it as it stands, partition_json() / partition_ndjson() skip the rewind for a stream that reports seekable() as False (#4643, fixed by #4649), and partition_tsv() copies it once to a temporary file.
To Reproduce
import io
import os
from unstructured.partition.email import partition_email
with open("example-docs/eml/fake-email.eml", "rb") as f:
eml_bytes = f.read()
reader_fd, writer_fd = os.pipe()
with os.fdopen(writer_fd, "wb") as writer:
writer.write(eml_bytes)
with os.fdopen(reader_fd, "rb") as reader:
print(partition_email(file=reader))
# io.UnsupportedOperation: File or stream is not seekable.
print(partition_email(file=io.BytesIO(eml_bytes))) # the same bytes, seekable: works
Expected behavior
partition_email(file=...) partitions a stream that cannot seek the way the sibling partitioners do, returning the same elements as the same bytes read from a seekable object.
Environment Info
- unstructured 0.27.38 (
mainat 2653935) - Python 3.12, macOS arm64
Additional context
This report is about calling partition_email(file=...) directly. #4677 describes the same error on the generic partition(file=...) entry point, where it comes from file-type detection; #4678 addresses that path.
- Lingua principale
- HTML
- Stelle
- 15.8k
- Fork
- 1.4k
- Merge medio
- 8g 4h
- PR unite (30g)
- 40
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Unstructured-IO/unstructured
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Unstructured-IO/unstructured#4876 ·
I maintainer di solito rispondono entro 6 giorni
-
fix(nlp): match single-letter bullets in the enumerated bullet patternForse già presa @Eapp1e l’ha presa 33 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Unstructured-IO/unstructured#4635 ·
I maintainer di solito rispondono entro 6 giorni
-
bug(cleaners): translate_text passes text instead of chunk in attention window loopForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
Unstructured-IO/unstructured#4558 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absentForse già presa @ayam04 l’ha presa 103 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Unstructured-IO/unstructured#4427 · 3 commenti ·
I maintainer di solito rispondono entro 6 giorni
-
Large HTML documents cannot be partitioned using the partition_html function.Forse già presa @CrepuscularIRIS l’ha presa 229 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
Unstructured-IO/unstructured#4289 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di Unstructured-IO/unstructured
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
epiforecasts/EpiNow2#1694 · 2 reazioni ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
component/core domain/framework
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bitwarden/directory-connector#1303 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno