Metadata accepts empty BytesIO/file values although empty is not allowed
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with Metadata.get_binary_from() in src/zimscraperlib/zim/metadata.py and compare how it handles bytes with BytesIO and file inputs. The issue reports two regression tests are ready; review or run them for both empty stream types. Done means empty streams raise the same ValueError as empty bytes. An open linked pull request already covers this issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Metadata.get_binary_from() (src/zimscraperlib/zim/metadata.py) checks the input object instead of the bytes it read:
if not self.empty_allowed and not value: # value is the BytesIO / file object
raise ValueError("Missing value (empty not allowed)")
return bvalue
io.BytesIO and file objects are always truthy, so an empty stream passes the check and an empty metadata entry ends up in the ZIM, while the same empty value given as bytes is rejected:
>>> import io
>>> from zimscraperlib.zim.metadata import CustomMetadata
>>> CustomMetadata("Foo", b"")
ValueError: Missing value (empty not allowed)
>>> CustomMetadata("Foo", io.BytesIO(b"")).value
b''
An empty file opened with "rb" is accepted the same way.
Expected: empty streams are rejected like empty bytes. Checking bvalue instead of value fixes it; I have that change with two regression tests (BytesIO and file) ready and can open a PR if that works for you.
- Lenguaje dominante
- Python
- Estrellas
- 33
- Forks
- 36
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 19
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 openzim/python-scraperlib
-
handle_user_provided_file leaves an empty temp filePosiblemente ocupada @kevincommits la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
openzim/python-scraperlib#414 ·
Los mantenedores suelen responder en 1 día
-
HtmlRewriter: title is cut at the first `&` (entity or bare ampersand)Posiblemente ocupada @rajanpanth la tomó hace 23 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
openzim/python-scraperlib#401 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[next major] Remove deprecated 'convert' parameter for optimize_image function inside optimization.pyPosiblemente ocupada @Sriram-Nambiar la tomó hace 51 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openzim/python-scraperlib#292 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Deduplicator: xxh32 digest can collide on large ZIMsPosiblemente ocupada @i-varunsharma la tomó hace 1 día. Abierto
openzim/python-scraperlib#426 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Detect and recover malformed inline data URLs missing the data: schemePosiblemente ocupada @Sriram-Nambiar la tomó hace 2 días. Abierto
openzim/python-scraperlib#420 · 2 reacciones · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de openzim/python-scraperlib
Issues similares
-
Relatório de erro do LinuxToysAbiertoauto-reported bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
backend bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
nolte/kamerplanter#3193 ·
Los mantenedores suelen responder en 1 día
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePosiblemente ocupada @abdulwaarith0 la tomó hoy. Abiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
MakazhanAlpamys/Soup#3690 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día