CLI exits 0 when compressing or hashing a file fails

Aperta Adatta ai principianti
#129 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia in cli.py, main(), nei gestori “Error hashing” e “Error compressing” e nel codice di ritorno finale. Verifica come la CLI gestisce gli errori dei worker e in che modo -q influisce sull’output; l’issue cita python -m servestatic.compress e Django storage come punti di confronto. Il lavoro è completato quando gli errori di hash o compressione indicano il nome del file su stderr anche con -q e fanno terminare la CLI con un codice diverso da zero.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Python Version

3.15.2

Django Version

N/A

Package Version

4.4.1

Description

Note: This bug was found and confirmed with the help of Claude. I have also used Claude to prepare this issue writeup

The servestatic command catches every exception from its compress and hash workers, prints a line, and returns 0 (cli.py, main(): the "Error hashing" and "Error compressing" handlers, then return 0). A CI job or container build that runs the CLI can't tell that a file failed. With -q nothing is printed either, so the failure is silent.

The Python API raises on the same failures: python -m servestatic.compress exits 1 on the directory below, and the Django storage raises too (#61, ported from whitenoise#615 "Raise errors from threads in whitenoise.compress"). So it looks like the CLI added in 4.0.0 (#96) brought the swallowing back by accident.

To reproduce:

mkdir -p src dest/app.js.br
python -c "open('src/app.js','w').write('console.log(1);\n'*500)"
servestatic src dest --compress --no-zstd
# Error compressing: [Errno 21] Is a directory: '.../dest/app.js.br'
echo $?    # 0
servestatic src dest --compress --no-zstd -q
echo $?    # 0, and nothing printed

Expected: a non-zero exit when any file fails to hash or compress, with each error printed to stderr, even under -q, naming the file.

Happy to send a pull request if that behaviour sounds right.

Lingua principale
Python
Stelle
109
Fork
7
Merge medio
1g 10h
PR unite (30g)
3

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.