Corrupt-PNG 422 detail mislabels content as SVG ("Invalid SVG content" for a PNG upload) #37

Closed
opened 2026-09-16 01:38:43 +00:00 by Mark · 1 comment
Owner

Summary

Uploading a corrupt PNG to /v1/digitize correctly returns 422 invalid_image, but the detail message mislabels the content type.

Repro (live, 2026-09-15)

POST /v1/digitize multipart with bytes notapng as bad.png (Content-Type: image/png).

Response: HTTP 422 {"error":"invalid_image","detail":"Semantic annotation failed: Invalid SVG content: syntax error: line 1, column 0"}

Expected

The detail should reflect what was actually attempted/received (e.g. "not a valid PNG"/"unrecognized image content"), not claim the upload was SVG. The 422 status and invalid_image code are correct — only the message misleads debugging.

Where to look

app.py — the digitize route's image-validation/annotation branch: the error path for non-SVG content appears to reuse the SVG parser's message regardless of the declared/actual content type.

Severity

P3 — cosmetic but burns debugging time on the corrupt-upload path (#27 class).

## Summary Uploading a corrupt PNG to `/v1/digitize` correctly returns 422 `invalid_image`, but the detail message mislabels the content type. ## Repro (live, 2026-09-15) `POST /v1/digitize` multipart with bytes `notapng` as `bad.png` (`Content-Type: image/png`). Response: HTTP 422 `{"error":"invalid_image","detail":"Semantic annotation failed: Invalid SVG content: syntax error: line 1, column 0"}` ## Expected The detail should reflect what was actually attempted/received (e.g. "not a valid PNG"/"unrecognized image content"), not claim the upload was SVG. The 422 status and `invalid_image` code are correct — only the message misleads debugging. ## Where to look `app.py` — the digitize route's image-validation/annotation branch: the error path for non-SVG content appears to reuse the SVG parser's message regardless of the declared/actual content type. ## Severity P3 — cosmetic but burns debugging time on the corrupt-upload path (#27 class).
Mark closed this issue 2026-09-18 13:30:37 +00:00
Author
Owner

Fixed in commit 40bf23a on origin/main.

The digitize route still returns 422 invalid_image, but the detail no longer claims an SVG-parser error for raster uploads. _decode_error_detail (pipeline_runner.py) detects when the engine returned an SVG-flavored error string for a payload that did not look like SVG, and substitutes a content-type-agnostic message: "image could not be decoded: the engine rejected the raster payload (engine reported an SVG-parser error for a non-SVG upload)". Real SVG uploads keep the engine error verbatim — only the mislabeling branch is rewritten.

Tests: 145 unit + 13 integration pass; ruff clean.

Fixed in commit 40bf23a on origin/main. The digitize route still returns 422 invalid_image, but the detail no longer claims an SVG-parser error for raster uploads. _decode_error_detail (pipeline_runner.py) detects when the engine returned an SVG-flavored error string for a payload that did not look like SVG, and substitutes a content-type-agnostic message: "image could not be decoded: the engine rejected the raster payload (engine reported an SVG-parser error for a non-SVG upload)". Real SVG uploads keep the engine error verbatim — only the mislabeling branch is rewritten. Tests: 145 unit + 13 integration pass; ruff clean.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/easystitch-service#37
No description provided.