Skip to content

Keep saving papers when an unmigrated Bucket cannot be set up - #1160

Merged
NielsRogge merged 1 commit into
mainfrom
claude/saved-papers-bucket-fallback
Nov 23, 2026
Merged

NielsRogge merged 1 commit into
mainfrom
claude/saved-papers-bucket-fallback

Conversation

@NielsRogge

@NielsRogge NielsRogge commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes huggingface/paperswithcode-feedback#58.

Problem

Some accounts approve saved-papers Bucket access, but Hugging Face refuses to create or write <user>/pwc-saved-papers (the reporter gets a non-HTTP write failure; production logs today show three other accounts getting 403s). Then:

  • Save returns 400 Hugging Face could not write the saved-papers Bucket.
  • /saved silently falls back to database bookmarks, so "Approve and migrate saved papers" round-trips through OAuth and shows the same button again, with no explanation.

135 accounts migrated fine, so this only affects accounts the Hub refuses.

Change

  • Until an account has migrated (saved_papers_bucket_migrated_at is null), save and unsave fall back to the database bookmarks when Bucket setup fails. Listings already read those bookmarks for unmigrated accounts. A later successful migration copies all of them, including saves made during the fallback.
  • Migrated accounts still fail on Bucket errors, and a missing authorization still returns 401, so the Bucket and the DB mirror can't diverge.
  • GET /me/bookmarks gets an additive bucket_error field. /saved shows the error and a retry button instead of the same migrate prompt.
  • Fallback warnings now log the underlying Hub exception, so the next report can be diagnosed.
  • The decision is recorded in ADR 0018.

Validation

  • pytest backend/tests/test_bookmarks_router.py backend/tests/paper/test_saved_papers_bucket.py: 20 passed, including new tests for the unmigrated fallback, the migrated failure and the listing error.
  • ruff check / ruff format --check, scripts/backend_comments.py check, eslint and tsc --noEmit all pass.

🤖 Generated with Claude Code


Note

Medium Risk
Changes bookmark write and read paths for accounts blocked by the Hub; migrated users still fail closed, but unmigrated users now persist only in the database until migration succeeds.

Overview
When Hugging Face refuses to create or write the saved-papers Bucket after OAuth, unmigrated accounts no longer fail on save/unsave: BookmarkService._require_bucket returns None instead of raising, and add/remove still update the database mirror. Migrated accounts continue to surface Bucket errors so the HF store and DB cannot diverge.

GET /me/bookmarks (and grouped listings) now expose an optional bucket_error when an authorized Bucket could not be used and legacy DB bookmarks were returned. Fallback logging includes the underlying Hub exception (__cause__).

The /saved UI shows that error with a “Try the Bucket migration again” action instead of repeating the generic approve prompt. Types and ADR 0018 document the behavior. New router tests cover unmigrated DB fallback, migrated failure, and listing error propagation.

Reviewed by Cursor Bugbot for commit 67c2b51. Bugbot is set up for automated code reviews on this repo. Configure here.

Some accounts approve saved-papers Bucket access but Hugging Face refuses
to create or write the Bucket. Save then returned 400 and /saved kept
offering the same approval, because the listing silently fell back to the
database bookmarks.

Until an account has migrated, save and unsave now write the database
bookmarks (the source listings already read) and succeed. The listing
returns the Bucket error so /saved explains the failure, and the
underlying Hub error is logged. Migrated accounts still fail on Bucket
errors so the Bucket and the database mirror cannot diverge.

Fixes huggingface/paperswithcode-feedback#58

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NielsRogge
NielsRogge merged commit b531bc7 into main Nov 23, 2026
6 checks passed
@NielsRogge
NielsRogge deleted the claude/saved-papers-bucket-fallback branch November 23, 2026 15:00
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.

Cannot bookmark/save papers

1 participant