Corrupt-PNG 422 detail mislabels content as SVG ("Invalid SVG content" for a PNG upload) #37
Labels
No labels
blocked:needs-attention
blocked:needs-decision
bug
feature-request
in-progress
needs-decompose
quickfix
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/easystitch-service#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Summary
Uploading a corrupt PNG to
/v1/digitizecorrectly returns 422invalid_image, but the detail message mislabels the content type.Repro (live, 2026-09-15)
POST /v1/digitizemultipart with bytesnotapngasbad.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_imagecode 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).
Fixed in commit
40bf23aon 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.