Skip to content

Fix translate-and-adapt for in-app articles (silent failure)#644

Merged
mircealungu merged 1 commit into
masterfrom
claude/translate-adapt-stored-article
May 28, 2026
Merged

Fix translate-and-adapt for in-app articles (silent failure)#644
mircealungu merged 1 commit into
masterfrom
claude/translate-adapt-stored-article

Conversation

@mircealungu
Copy link
Copy Markdown
Member

Summary

A user opened a foreign-language article in the reader, chose Translate to my level, saw "Translating…", and then nothing happened. Reproduced from logs:

Failed to detect source language: Readability failed to parse article
Translation failed for https://zeeguu.org/read/article?id=4604129:
  cannot access local variable 'article_obj' where it is not associated with a value
POST //translate_and_adapt_article ... 500

Two compounding bugs (this PR is the backend half):

  1. /translate_and_adapt_article re-downloaded the article's stored URL through readability. For articles whose stored URL is a Zeeguu reader link (zeeguu.org/read/article?id=…, a JS SPA), the download failed — and the code then fell through and used the never-assigned article_obj, raising UnboundLocalError → HTTP 500.
  2. (Web PR) the reader swallowed the error and just closed the modal.

Changes

  • Endpoint now accepts article_id and translates the already-stored article content directly — no re-download, no readability dependency — and reuses the stored image.
  • The URL path (external shares) is kept, but now abort(502) cleanly instead of crashing when a fetch fails.

Companion PR

  • web: claude/translate-adapt-stored-article (passes article_id, graceful fallback)

Test plan

  • Open a foreign-language article in the reader (deeplink) and tap Translate to my level → navigates to the translated/adapted version
  • Article whose stored URL is a Zeeguu reader link (e.g. id 4604129) translates successfully
  • External share of a normal URL still translates (URL path)
  • Unfetchable URL returns 502, not 500

🤖 Generated with Claude Code

When a user opened a foreign-language article in the reader and chose
"Translate to my level", the request silently failed and nothing happened.

Two compounding bugs:
- The endpoint re-downloaded the article's stored URL through readability.
  For articles whose stored URL is a Zeeguu reader link (a JS page), the
  download failed; the code then fell through and used the never-assigned
  `article_obj`, raising UnboundLocalError -> HTTP 500.
- The web reader swallowed that error and just closed the modal.

The endpoint now accepts `article_id` and translates the already-stored
article content directly (no re-download, no readability dependency), reusing
its image. The URL path is kept for external shares but now aborts cleanly
(502) instead of crashing when a fetch fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

ArchLens - No architecturally relevant changes to the existing views

@mircealungu mircealungu merged commit f63e924 into master May 28, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant