Conversation
DeleteUser now cascades to session cleanup in both memory and Firestore backends, and the admin handler terminates live stdio sessions before deletion. Firestore TrackSession and UpsertUser no longer do racy read-before-write — TrackSession uses a simple Set, UpsertUser uses a transaction. Memory TrackSession respects caller-provided Created timestamps. Admin dashboard filters stale sessions. BrowserCookie gets an IsExpired() method used by middleware.
Summary of ChangesHello @dgellow, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses several critical session lifecycle management issues across both memory and Firestore storage backends. It ensures robust cleanup of user-related sessions upon user deletion, prevents race conditions during user and session updates, and improves the accuracy of the admin dashboard by filtering out stale sessions. The changes enhance data consistency and system reliability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request introduces several important fixes and improvements related to session lifecycle management and user deletion. Key changes include implementing cascading session cleanup for both in-memory and Firestore backends when a user is deleted, ensuring that live stdio sessions are terminated by the admin handler. The Firestore UpsertUser and TrackSession methods have been refactored to use transactions and direct Set operations, respectively, addressing potential race conditions. Additionally, a new IsExpired() method has been added to BrowserCookie for better encapsulation of expiration logic, and the admin dashboard now filters stale sessions. Comprehensive tests have been added for the memory storage session functionality, which is a great addition.
| sessions, sessErr := h.storage.GetActiveSessions(r.Context()) | ||
| if sessErr == nil { |
There was a problem hiding this comment.
If h.storage.GetActiveSessions(r.Context()) returns an error, this error is not logged, and the session termination logic is silently skipped. This could lead to active sessions for a deleted user not being terminated if there's a temporary issue with session retrieval from storage. It's important to log such errors to ensure visibility into potential cleanup failures.
sessions, sessErr := h.storage.GetActiveSessions(r.Context())
if sessErr != nil {
log.LogErrorWithFields("admin", "Failed to get active sessions for user deletion", map[string]any{
"error": sessErr.Error(),
"userEmail": targetEmail,
})
} else {
for _, s := range sessions {
DeleteUser now cascades to session cleanup in both memory and Firestore backends, and the admin handler terminates live stdio sessions before deletion. Firestore TrackSession and UpsertUser no longer do racy read-before-write — TrackSession uses a simple Set, UpsertUser uses a transaction. Memory TrackSession respects caller-provided Created timestamps. Admin dashboard filters stale sessions. BrowserCookie gets an IsExpired() method used by middleware.