Return translate/simplify upload failures as JSON (make_error), 422#661
Merged
Conversation
These user-initiated conversion failures used flask.abort, which renders HTML,
so the web client's response.json() failed and it could only show "HTTP 4xx" /
a hardcoded generic. Switch to make_error (jsonify {message}) so the actionable
text ("…too long… try a single chapter") reaches the reader.
Also drops simplify from 500 to 422 to match translate: an over-long upload is
a content issue, not a server fault, and shouldn't page on-call.
Pairs with zeeguu/web#1183 (reader surfaces the message).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to #660.
The user-initiated conversion endpoints (
/article_upload/<id>/translate_and_adapt,/simplify) reported failure withflask.abort(...), which renders an HTML error page. The web client doesresponse.json()on errors, so it never saw the message and fell back toHTTP 4xx/ a hardcoded generic.Switch both to
make_error(status, msg)(the repo'sjsonify({"message": ...})helper) so the actionable text — "…too long to process in one piece — try importing a single chapter" — reaches the reader.Also drops the simplify failure from
500to422to match translate: an over-long upload is a content issue, not a server fault, and shouldn't page on-call.Pairs with zeeguu/web#1183, which updates the reader to display the message.
🤖 Generated with Claude Code