Repository navigation
fix(api): let 5xx errors through the tool routes' 422 catch-all - #1667
Conversation
Refs snapotter-hq#1640. A full workspace or failed storage write inside these routes was answered as a 422 bad file. Rethrow errors carrying a 5xx statusCode, as image-to-pdf already does for isDecoderUnavailable.
|
Review notes before merge. Nothing blocking turned up. The new tests fail on the base commit, and the global error handler logs, reports, and answers the rethrown 503/507 with their message and code, so skipping the per-route Filed as #1671: five catches with the same shape that this PR doesn't touch. They're the Left to #1640: bridge errors with Not actioned:
|
|
Thanks @drakeo338. Storage failures in these 13 routes now come back as a 503 or 507 with a real message, not a 422 that blames the user's file. As a side effect, five of them now report a missing decoder correctly too. Merged as submitted, and it ships in the next release. The routes this didn't cover are tracked in #1671 if you want to pick them up. |
qr-generate, html-to-image, passport-photo generate and the content-aware-resize input-prep catch now rethrow errors carrying a 5xx statusCode instead of answering 422, matching #1667. In html-to-image the rethrow runs before the timeout/browser message checks. sign-pdf is left to #1640 because a waitForJob rejection carries no status. Closes #1671
What does this PR do?
Refs #1640. The hand-written tool routes answered 422 for any error in their catch-all, so a full workspace or failed write read as a bad file. They now rethrow errors carrying a 5xx
statusCode, likeimage-to-pdfdoes forisDecoderUnavailable, via a small sharedhasServerErrorStatuspredicate. Does not close #1640 (the factory route).Routes: svg-to-raster (and its presets), image-to-pdf, beautify, compare, compose, content-aware-resize, edit-metadata, meme-generator, stitch, vectorize, watermark-image, passport-photo (analyze), remove-background.
Skipped: pdf-to-image (overlaps #1552).
Tests: new unit test drives svg-to-raster and compare with
putObjectthrowing 507/503 (now surfaced) and a plain error (still 422).Type of change
Checklist
pnpm test)pnpm typecheck)Screenshots (if applicable)
Not applicable.
🤖 Generated with Claude Code