Repository navigation
Conversation
…ttern The reserved-id check added in google#7801 used startswith("__") and endswith("__"), which also matches "__" and "___" because the prefix and suffix overlap. Firestore reserves only ids matching __.*__, which needs at least four characters, so those two valid ids were rejected and any sessions already stored under them could no longer be read or deleted. Require a minimum length of four so the check is equivalent to re.fullmatch(r"__.*__", value). Fixes google#7855
CorgiBoyG
force-pushed
the
fix/firestore-reserved-id-length
branch
from
November 1, 2026 15:16
fa17d53 to
b61a33d
Compare
copybara-service Bot
pushed a commit
that referenced
this pull request
Nov 2, 2026
Merge #7858 FirestoreSessionService again accepts "__" and "___" as app_name, user_id or session_id, so sessions stored under them are readable and deletable through the service. Ids of four or more characters that start and end with "__" are still rejected. Fixes #7855 PiperOrigin-RevId: 1012330913
Collaborator
|
Thank you @CorgiBoyG for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit e533f55. Closing this PR as the changes are now in the main branch. |
2 tasks done
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.
Link to Issue or Description of Change
Problem:
The reserved-id check added in #7801 uses:
Firestore reserves only ids that fully match
__.*__, which needs at least four characters. Because the prefix and suffix overlap, the check above also matches"__"and"___". Those are valid Firestore document ids and do not change the document path, butFirestoreSessionServicenow rejects them, and any sessions already stored under them can no longer be read or deleted through the service.Solution:
Require a minimum length of four characters:
This makes the check equivalent to
re.fullmatch(r"__.*__", value). Nothing else in the validation changes:/,.,.., empty ids and genuinely reserved ids such as"____"and"__x__"are still rejected, so the path-injection protection from #7800 is unaffected.Testing Plan
Unit Tests:
New tests:
test_validate_identity_component_matches_firestore_reserved_patternchecks"__","___","____","__x__","__alice"and"alice__"against the reserved rule.test_create_session_accepts_short_underscore_identitychecks thatcreate_sessionaccepts"__"and"___"asuser_id.The 4 cases for
"__"/"___"fail on current main withValueError: user_id must not match the Firestore-reserved __.*__ patternand pass with the fix.I also compared the check against
re.fullmatch(r"__.*__", value)for every string over{"_", "a"}up to length 8 (510 values): 0 mismatches.Static checks:
The full repository test suite was not run.
Manual End-to-End (E2E) Tests:
Not run. The change is limited to the id validation predicate, which is covered by the unit tests above.
Checklist
Additional context
This boundary was introduced by my own change in #7801.