Update context.me - #865
Open
SharonStrats wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The newly introduced login/profile race-handling paths are not covered by existing unit tests, increasing the risk of regressions in authentication flow.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses a login/profile-loading race by ensuring the authenticated user is saved into the AuthenticationContext when a session is already active, so downstream code relying on context.me can proceed reliably.
Changes:
- Call
authn.saveUser()whenauthn.checkUser()indicates an existing logged-in session. - In
ensureLoadedProfile(), resolve the WebID viacontext.meorauthn.currentUser(), and backfillcontext.mewhen missing before loading the profile.
File summaries
| File | Description |
|---|---|
| src/login/login.ts | Ensures the auth context is populated from existing sessions/current user to avoid context.me being empty during profile load. |
Review details
Suppressed comments (1)
src/login/login.ts:209
- ensureLoadedProfile now falls back to authn.currentUser() and conditionally calls authn.saveUser() to populate context.me; this race-condition behavior change is not covered by tests. Please add a unit test that exercises the scenario where ensureLoggedIn resolves but context.me is still unset while authn.currentUser() returns a user, and assert that the profile load uses that resolved user and updates context accordingly.
const logInContext = await ensureLoggedIn(context)
const resolvedMe = logInContext.me || authn.currentUser()
if (!resolvedMe) {
throw new Error('Could not log in')
}
if (!logInContext.me) {
authn.saveUser(resolvedMe as any, context)
}
context.publicProfile = await loadProfile(resolvedMe)
- Files reviewed: 1/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Prompt: Add a test that checks ensureLoggedIn() calls authn.saveUser() when authn.checkUser() returns a WebID. Co-authored-by: GPT-5.4 Mini <gpt-5.4-mini@openai.com>
SharonStrats
force-pushed
the
fix/context-me
branch
from
September 8, 2026 01:44
eb3fa34 to
c3b3497
Compare
…istry@5.0.0-0) (latest: rdflib@2.4.0)
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.
When researching an issue we are having with PATCH on the profile card resource, creating lots of logs led to exposing the following small bug.
Note: this did not fix the PATCH issue.
The logs showed the login flow actually entering ensureLoggedIn() and then ensureLoadedProfile(), and they exposed a race where authn.currentUser() was already available but context.me was still empty. So I have added a saveuser call to refresh the context.