Metadata accepts empty BytesIO/file values although empty is not allowed
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 33
- Forks
- 36
- Merge médio
- 1d 10h
- PRs com merge (30d)
- 19
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de openzim/python-scraperlib
-
handle_user_provided_file leaves an empty temp fileTalvez já em andamento @kevincommits assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
openzim/python-scraperlib#414 ·
Mantenedores costumam responder em até 1 dia
-
HtmlRewriter: title is cut at the first `&` (entity or bare ampersand)Talvez já em andamento @rajanpanth assumiu há 23 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
openzim/python-scraperlib#401 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[next major] Remove deprecated 'convert' parameter for optimize_image function inside optimization.pyTalvez já em andamento @Sriram-Nambiar assumiu há 51 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
openzim/python-scraperlib#292 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Deduplicator: xxh32 digest can collide on large ZIMsTalvez já em andamento @i-varunsharma assumiu há 1 dia. Aberta
openzim/python-scraperlib#426 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Detect and recover malformed inline data URLs missing the data: schemeTalvez já em andamento @Sriram-Nambiar assumiu há 2 dias. Aberta
openzim/python-scraperlib#420 · 2 reações · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de openzim/python-scraperlib
Issues semelhantes
-
auto-reported bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
backend bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
nolte/kamerplanter#3193 ·
Mantenedores costumam responder em até 1 dia
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwiseTalvez já em andamento @abdulwaarith0 assumiu hoje. Abertaneeds-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
MakazhanAlpamys/Soup#3690 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia