feat: `ByteStream.from_file_path` should keep the file path in `meta`
Los mantenedores suelen responder en 1 día
@pinjun99 ya está trabajando en esto.
Desde el 4/12/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
Línea de trabajo
Empieza leyendo ByteStream.from_file_path y sus pruebas; el issue no indica sus rutas de archivo, así que localízalas en el repositorio. Comprueba cómo combina el método meta proporcionado por quien lo llama con la ruta y, después, compara el comportamiento del conversor con lo descrito en el issue. El trabajo estará terminado cuando los streams creados a partir de rutas incluyan file_path de forma predeterminada, se conserve el meta["file_path"] explícito y las pruebas cubran ambos casos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 27.2k
- Forks
- 3.5k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 254
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de deepset-ai/haystack
-
BlockingConfirmationStrategy ignores an empty argument replacementPosiblemente ocupada @sjrl la tomó hace 6 días. AbiertoP1
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
deepset-ai/haystack#13863 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
CSVToDocument row mode fails on CR-separated CSV inputPosiblemente ocupada @julian-risch la tomó hace 66 días. AbiertoP3
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
deepset-ai/haystack#13022 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
CSVToDocument row mode drops a real extra_columns field on ragged rowsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertohandled internally P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
deepset-ai/haystack#12994 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CSVDocumentCleaner deletes a row that says N/A, and both CSV components empty those cellsPosiblemente ocupada @michaelkillgta la tomó hace 72 días. AbiertoP3
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
deepset-ai/haystack#12784 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Use JSX comments for docstringsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoP2 type:documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
deepset-ai/haystack#11104 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de deepset-ai/haystack
Issues similares
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertogood first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
omarelshamy25x/shamy-hijri#63 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
polish
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPosiblemente ocupada @AshutoshSingh840 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
UKGovernmentBEIS/control-arena#992 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Los mantenedores suelen responder en 1 día