Skip to content

Fix handling of orphaned UserWords (no bookmarks)#480

Open
mircealungu wants to merge 2 commits intomasterfrom
fix-orphaned-userwords-handling
Open

Fix handling of orphaned UserWords (no bookmarks)#480
mircealungu wants to merge 2 commits intomasterfrom
fix-orphaned-userwords-handling

Conversation

@mircealungu
Copy link
Member

Summary

  • Fix 'NoneType' has no attribute 'text' errors in Sentry caused by orphaned UserWords
  • as_dictionary() now handles orphaned UserWords gracefully, returning minimal data (word, translation, rank)
  • article.py clear_bookmarks() now properly marks UserWords as unfit when bookmarks are cleared
  • Orphaned words are preserved for historical data (learned words list) but excluded from exercises

Changes

  • user_word.py: Auto-repair when bookmarks exist but preferred is None; return minimal data for truly orphaned words; add is_orphaned flag
  • article.py: Mark UserWords as unfit when clearing bookmarks leaves them orphaned
  • bookmarks_and_words.py: Keep existing behavior (mark unfit, preserve history)
  • exercises.py: Simplified error handling since orphans are handled gracefully

Test plan

  • All existing tests pass
  • Verify learned words list shows orphaned words correctly (word + translation, no context)
  • Verify exercises don't include orphaned words
  • Verify deleting bookmark marks UserWord as unfit

🤖 Generated with Claude Code

Problem:
- UserWords could become orphaned (no bookmarks) when bookmarks were
  deleted, causing 'NoneType' has no attribute 'text' errors in Sentry
- article.py clear_bookmarks() didn't mark UserWords as unfit for study
- Orphaned words with fit_for_study=1 appeared in exercises but crashed

Solution:
- as_dictionary() now handles orphaned UserWords gracefully:
  - Auto-repairs when bookmarks exist but preferred_bookmark is None
  - Returns minimal data for truly orphaned words (word, translation, rank)
  - Adds is_orphaned flag so frontend knows context is unavailable
- article.py clear_bookmarks() now marks UserWords as unfit when orphaned
- exercises.py simplified error handling (orphans handled gracefully)

Design:
- Orphaned words are kept for historical data (learned words list)
- They appear in history with word+translation but no context
- They're excluded from exercises via fit_for_study=false
- When user translates word again, new bookmark is created

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 10, 2026

ArchLens detected architectural changes in the following views:
diff

Shows minutes per month for:
- Exercises (red)
- Reading (blue)
- Browsing (green)
- Audio lessons (purple)

With caching like monthly active users.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

Comments