Visione: file non immagine o grafo malformato → 500 del worker, 502 senza motivo al Maker #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRAVITÀ: alta
FILE: src/vision_worker/main.py:38-48 ; src/backend/api/routers/vision.py:49 ; src/backend/api/routers/tasks.py:182
COSA:
Image.opensta fuori dal try; è gestito soloValueError.UnidentifiedImageError, eKeyError/AttributeError/TypeErrordiTask.from_dict, diventano 500. Il backend controlla solo l'header content_type;vision_jsonnon è validato alla creazione del task.INPUT: (a) file di testo dichiarato image/png; (b) graph="[]"; (c) strumento senza "kind". Tutti → 500 worker → 502 «refused the job: Internal Server Error». Dovrebbe essere 422 con motivo.
VERIFICATO: lettura di main.py:24-48; probe TestClient del revisore (Python 3.13) → A, B, C = 500.
ORIGINE: revisione fable del 21/09/2026 su ramo
V3.0.0, commit8cc5e82. Documento completo:_output/2026-09-21-TieMeasureFlow-revisione.mdsu Wasabi.⚡ jeeg — preso in carico 2026-09-21T20:22:32Z
ramo:
lavoro/jeeg· capacità: docker, gpu, systemdANALISI (passo 1) — ramo
lavoro/jeeg, worktree~/lavoro/TieMeasureFlowsu jeeg, lotto C1MODIFICHE: src/vision_worker/main.py —
Image.open(...).convertdentro try:UnidentifiedImageError/OSError→ 422 «image is not decodable»; attorno arun_graph:KeyError,TypeError,AttributeError,ValueErrorprovenienti dalla costruzione del grafo → 422 «malformed graph: : ». Distingui costruzione ed esecuzione sesrc/vision/runner.pylo permette (due fasi: build → 422, run → 500 con motivo nel detail). Il grafo deve essere un dict: lista/altro → 422. src/backend/services/vision_service.py: un 422 del worker si propaga come 422 con il detail del worker (non 502). src/backend/api/routers/vision.py:49: verifica i magic bytes dell'immagine (PNG/JPEG/BMP/TIFF/WebP/GIF) → 415/422 prima di chiamare il worker.TEST: src/vision_worker/tests/test_worker.py (Python 3.13,
uv run --python 3.13 --extra vision-worker --extra dev pytest src/vision src/vision_worker): file di testo → 422; graph[]→ 422; strumento senzakind→ 422. Base: scratchpad/probe_worker.py.NON TOCCARE: vendor/visionsuite; src/backend/api/routers/tasks.py.
Soluzione
ESITO: fatto
COSA: Worker: immagine non decodificabile, grafo non-oggetto o malformato (
GraphBuildError) → 422 con motivo; errore in esecuzione → 500 con tipo e messaggio. Il backend inoltra 422/503/504 del worker e verifica i magic bytes dell'immagine prima di chiamarlo.COMMIT (ramo lavoro/jeeg, unito su V3.0.0 a
d483fa1):9afe1e7PROVA:
uv run --extra server --extra client --extra dev pytest -q→ 622 passed, 4 skipped (erano 391); visione su Python 3.13 → 16 passed (erano 8).