Skip to content

Fix GitHub user cache consistency and fallback session shape#296

Open
Esubaalew wants to merge 1 commit intobetter-auth:mainfrom
Esubaalew:fix/auth-github-user-cache
Open

Fix GitHub user cache consistency and fallback session shape#296
Esubaalew wants to merge 1 commit intobetter-auth:mainfrom
Esubaalew:fix/auth-github-user-cache

Conversation

@Esubaalew
Copy link
Contributor

@Esubaalew Esubaalew commented Mar 5, 2026

Summary

This fixes the GitHub user cache by making the read and write paths use the same Redis key. Before this, the code read from github_user:${token} but wrote to github_user:${hash}, so cached GitHub profiles were effectively never reused.

additional thing I made just because I wanted to improve

It also makes getOctokitUser() return a consistent profile shape, updates getServerSession() to return a safe fallback GitHub user object instead of an incomplete access-token-only object when the GitHub fetch fails,
also some type warning fixes unrelated to the PR but cool to fix

Keep cached GitHub profile reads and writes on the same key, and make degraded GitHub user sessions fail safely instead of returning an incomplete object.
Copilot AI review requested due to automatic review settings March 5, 2026 22:38
@vercel
Copy link

vercel bot commented Mar 5, 2026

@Esubaalew is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants