Repository navigation
Create saved-papers Buckets under the Hub's username casing - #1161
Merged
Merged
Conversation
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>
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 #1160 for the saved-papers 403s.
Problem
With #1160 logging the Hub's message, the remaining saved-papers failures read:
The Hub accounts are
Andrex14andShuYou77877.require_userlowercases 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_useralso returnshub_username: the session username with its exact Hub casing. Existing sessions already carry it, so no re-login is needed.SavedPapersBucketuses it for the Bucket ID. Database keys stay lowercase.Validation
pytestbookmark, saved-papers Bucket andrequire_usertests: 23 passed, including a new test that the Bucket gets the exact-case namespace.ruff check,ruff format --checkandscripts/backend_comments.py checkall 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_usernow exposeshub_username(session JWT casing) alongside the existing lowercaseusername. Bookmark routes pass both through toBookmarkService, which instantiatesSavedPapersBucketwithhub_username or usernamewhile 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.