mirror of
https://github.com/niels-emmer/myace.git
synced 2026-09-14 07:36:39 +02:00
[PR #70] [MERGED] fix: GitHub OAuth callback 500s fetching userinfo — KeyError: userinfo_endpoint #70
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
github-mirrors/myace#70
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/niels-emmer/myace/pull/70
Author: @niels-emmer
Created: 8/12/2026
Status: ✅ Merged
Merged: 8/12/2026
Merged by: @niels-emmer
Base:
main← Head:fix/github-userinfo-endpoint📝 Commits (1)
a99dd59fix: GitHub OAuth callback 500s fetching userinfo (KeyError: userinfo_endpoint)📊 Changes
5 files changed (+199 additions, -9 deletions)
View changed files
📝
AGENTS.md(+15 -0)📝
backend/app/api/auth.py(+37 -4)📝
backend/app/core/security.py(+5 -0)📝
backend/tests/test_oauth_callback.py(+134 -5)📝
docs/extending.md(+8 -0)📄 Description
Summary
Third production bug in the OAuth flow, found by the user actually completing a real GitHub registration end-to-end now that the previous two fixes (#67 redirect_uri scheme, #68 PKCE code_verifier) got them past the earlier failure points for the first time.
.well-known/openid-configurationdiscovery document.get_oauth_client()'s GitHub registration never setapi_base_url/userinfo_endpoint, so Authlib's genericclient.userinfo(token=token)(called because GitHub's token response has nouserinfo/id_token) raisedKeyError: 'userinfo_endpoint'trying to read it from empty discovery metadata.api_base_url="https://api.github.com/"/userinfo_endpoint="https://api.github.com/user"explicitly in the GitHub client registration./userresponse uses different field names than OIDC claims (idnotsub,login/avatar_urlnotpreferred_username/picture), and itsemailfield isnullunless the user made one public — true even with theuser:emailscope granted.auth_callback()now branches onprovider == "github"to map the real fields, falling back toGET /user/emailsfor the primary verified address whenemailis null. If a user truly has no verified email at all, they now get a clear 400 instead of crashing onUser.email'sNOT NULL/UNIQUEconstraint.Test plan
test_oauth_callback.pywith aFakeGitHubClient(GitHub-shaped responses, no network) covering: normal field normalization, private-email fallback to/user/emails, and the no-verified-email 400 rejection.githubtooidcso they test PKCE mechanics without coupling to GitHub's field-mapping logic (they were incidentally usinggithubas a stand-in "any provider" before this fix introduced provider-specific branching).auth_callback()fix locally and confirmed the 3 new GitHub tests fail with the exact error shapes (KeyError/AttributeError) GitHub's real response would actually produce; restored and confirmed all pass.ruff checkclean.AGENTS.mdanddocs/extending.mdso the next non-OIDC provider gets the same treatment.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.