Metadata accepts empty BytesIO/file values although empty is not allowed
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 33
- Fork
- 36
- Merge medio
- 1g 10h
- PR unite (30g)
- 19
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 openzim/python-scraperlib
-
handle_user_provided_file leaves an empty temp fileForse già presa @kevincommits l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
openzim/python-scraperlib#414 ·
I maintainer di solito rispondono entro 1 giorno
-
HtmlRewriter: title is cut at the first `&` (entity or bare ampersand)Forse già presa @rajanpanth l’ha presa 23 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
openzim/python-scraperlib#401 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[next major] Remove deprecated 'convert' parameter for optimize_image function inside optimization.pyForse già presa @Sriram-Nambiar l’ha presa 51 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openzim/python-scraperlib#292 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Deduplicator: xxh32 digest can collide on large ZIMsForse già presa @i-varunsharma l’ha presa 1 giorno fa. Aperta
openzim/python-scraperlib#426 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Detect and recover malformed inline data URLs missing the data: schemeForse già presa @Sriram-Nambiar l’ha presa 2 giorni fa. Aperta
openzim/python-scraperlib#420 · 2 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openzim/python-scraperlib
Issue simili
-
auto-reported bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
backend bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
nolte/kamerplanter#3193 ·
I maintainer di solito rispondono entro 1 giorno
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwiseForse già presa @abdulwaarith0 l’ha presa oggi. Apertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
MakazhanAlpamys/Soup#3690 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno