feat: `ByteStream.from_file_path` should keep the file path in `meta`
I maintainer di solito rispondono entro 1 giorno
@pinjun99 ci sta già lavorando.
Dal 4/12/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
Direzione di ricerca
Inizia leggendo ByteStream.from_file_path e i relativi test; l’issue non indica i loro percorsi, quindi individuali nel repository. Controlla come il metodo combina meta fornito da chi lo chiama con il percorso, quindi confronta il comportamento del convertitore con quanto descritto nell’issue. Il lavoro è completo quando gli stream creati da percorsi includono file_path per impostazione predefinita, meta["file_path"] esplicito viene preservato e i test coprono entrambi i casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
I was playing with a small RAG pipeline on Windows. Most of my text files are UTF-8, but one is an older file saved in cp1252. To give just that one file its own encoding, I loaded it with ByteStream.from_file_path(path, meta={"encoding": "cp1252"}) and passed it to TextFileToDocument together with the other paths.
The encoding part worked nicely, but I noticed that document had no file_path in its meta, while all the others did. In a RAG app that's usually what you show as the source of an answer, so that one document quietly lost its source.
Here's a minimal example:
from pathlib import Path
from haystack.components.converters import TextFileToDocument
from haystack.dataclasses import ByteStream
path = Path("notes.txt")
path.write_text("Some notes.", encoding="utf-8")
converter = TextFileToDocument()
# From a path: file_path is set
print(converter.run(sources=[path])["documents"][0].meta)
# {'file_path': 'notes.txt'}
# From ByteStream.from_file_path: file_path is missing
stream = ByteStream.from_file_path(path)
print(converter.run(sources=[stream])["documents"][0].meta)
# {}
Describe the solution you'd like
It would be great if ByteStream.from_file_path added file_path to meta on its own. If someone already passes their own file_path in meta, theirs should win. Converters already shorten it to just the file name when store_full_path=False, so documents would end up with the same metadata whether they came from a path or a ByteStream.
Describe alternatives you've considered
Right now I can pass it myself: meta={"encoding": "cp1252", "file_path": str(path)}. That works, but it's easy to forget, and nothing tells you when you do.
Additional context
Haystack itself does this by hand right after calling from_file_path, in two places:
get_bytestream_from_sourceinhaystack/components/converters/utils.py:bs.meta["file_path"] = str(source)haystack/components/converters/image/image_utils.py:ByteStream.from_file_path(pdf_path, meta={"file_path": str(pdf_path)})
Also, the similar FileContent.from_file_path already keeps the file name (filename = filename or file_path.name), so this would make the two behave the same way.
If this sounds reasonable, I'd be happy to open a PR with the change and tests.
Tested on main (3.6.0-rc0), Windows 11, Python 3.14.
- Lingua principale
- Python
- Stelle
- 27.2k
- Fork
- 3.5k
- Merge medio
- 1g 18h
- PR unite (30g)
- 254
Preparare l'ambiente
- Nessun Dockerfile né 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 deepset-ai/haystack
-
BlockingConfirmationStrategy ignores an empty argument replacementForse già presa @sjrl l’ha presa 6 giorni fa. ApertaP1
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
deepset-ai/haystack#13863 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
CSVToDocument row mode fails on CR-separated CSV inputForse già presa @julian-risch l’ha presa 66 giorni fa. ApertaP3
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
deepset-ai/haystack#13022 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
CSVToDocument row mode drops a real extra_columns field on ragged rowsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertahandled internally P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
deepset-ai/haystack#12994 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CSVDocumentCleaner deletes a row that says N/A, and both CSV components empty those cellsForse già presa @michaelkillgta l’ha presa 72 giorni fa. ApertaP3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
deepset-ai/haystack#12784 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Use JSX comments for docstringsForse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaP2 type:documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
deepset-ai/haystack#11104 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di deepset-ai/haystack
Issue simili
-
Test: to_hijri() accepts datetime.datetime and uses only the date partForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertagood first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
polish
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresForse già presa @AshutoshSingh840 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
UKGovernmentBEIS/control-arena#992 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
mvalentsev/awesome-free-ai-coding#70 ·
I maintainer di solito rispondono entro 1 giorno