Skip to content

Create saved-papers Buckets under the Hub's username casing - #1161

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

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

Conversation

@NielsRogge

@NielsRogge NielsRogge commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1160 for the saved-papers 403s.

Problem

With #1160 logging the Hub's message, the remaining saved-papers failures read:

403 Forbidden: You have read access but not the required permissions for this operation.
Cannot access content at: https://huggingface.co/api/buckets/andrex14/pwc-saved-papers.

The Hub accounts are Andrex14 and ShuYou77877. require_user lowercases the session username because it keys bookmarks and preferences in the database (all 17,748 preference rows are lowercase). The saved-papers Bucket reused that lowercased name as its Hub namespace, so any account with uppercase letters could never create its Bucket. Since #1160, saving already falls back to the database for these accounts; this change lets them actually migrate.

Change

  • require_user also returns hub_username: the session username with its exact Hub casing. Existing sessions already carry it, so no re-login is needed.
  • The bookmark endpoints pass it through, and SavedPapersBucket uses it for the Bucket ID. Database keys stay lowercase.
  • No account with uppercase letters could ever have created a lowercase-namespace Bucket, so no existing Bucket moves.

Validation

  • pytest bookmark, saved-papers Bucket and require_user tests: 23 passed, including a new test that the Bucket gets the exact-case namespace.
  • ruff check, ruff format --check and scripts/backend_comments.py check all pass.

🤖 Generated with Claude Code


Note

Medium Risk
Touches bookmark read/write and Hub Bucket identity for all signed-in users; behavior change is narrow (casing only) but failures would affect saved-papers migration and sync.

Overview
Fixes 403 errors when users with mixed-case Hugging Face usernames (e.g. Andrex14) try to use saved-papers Buckets. The app had been building Bucket namespaces from the lowercased session username used for database keys, which does not match the Hub account name.

require_user now exposes hub_username (session JWT casing) alongside the existing lowercase username. Bookmark routes pass both through to BookmarkService, which instantiates SavedPapersBucket with hub_username or username while DB lookups and mirrors still use the lowercase name.

A new test asserts the Bucket is created under the exact-case Hub namespace.

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

require_user lowercases the session username because it keys bookmarks
and preferences in the database. The saved-papers Bucket reused that
lowercased name as its Hub namespace, so accounts with uppercase letters
(for example Andrex14) got 403 "read access but not the required
permissions" when creating andrex14/pwc-saved-papers and could never
migrate.

require_user now also returns hub_username with the session's exact
casing, and the Bucket uses it while the database keeps the lowercase key.

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