[PR #311] [CLOSED] fix: sync GitHub profile on login to handle username renames (#303) #324

Closed
opened 2026-02-15 17:16:54 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/311
Author: @ianalloway
Created: 2/14/2026
Status: Closed

Base: mainHead: main


📝 Commits (6)

  • 3f4bb8f fix: sync GitHub profile on login to handle username renames (#303)
  • 19ec3e7 Merge pull request #1 from ianalloway/devin/1771109978-fix-github-username-sync
  • 7ab1862 fix: allow updating skill summary/description on subsequent publishes (#301)
  • 36078ad Merge pull request #2 from ianalloway/devin/1771112524-skill-metadata-update
  • 1d53b25 Merge branch 'main' into main
  • 331ba0d Update convex/users.ts

📊 Changes

2 files changed (+16 additions, -0 deletions)

View changed files

📝 convex/auth.ts (+7 -0)
📝 convex/lib/githubAccount.ts (+9 -0)

📄 Description

Summary

Fixes #303 - When a user renames their GitHub account, the stored username becomes stale and causes "GitHub account lookup failed" errors during skill publishing.

This PR adds a background sync that runs on every login to keep the user's GitHub profile (username, avatar) up-to-date:

  1. syncGitHubProfile - Fetches current profile from GitHub API using the immutable numeric user ID
  2. syncGitHubProfileInternal - Mutation that updates name, handle, displayName, and image fields when the username changes
  3. Auth callback integration - Schedules the sync as a background action via ctx.scheduler.runAfter(0, ...) so it doesn't block sign-in

The sync is best-effort: if the GitHub API is unavailable, it logs a warning and continues silently.

Changes

  • convex/lib/githubAccount.ts: Added syncGitHubProfile function
  • convex/users.ts: Added syncGitHubProfileInternal mutation and syncGitHubProfileAction internal action
  • convex/auth.ts: Integrated sync into afterUserCreatedOrUpdated callback

Greptile Overview

Greptile Summary

Added background GitHub profile sync on login to handle username renames by fetching current profile data using the immutable numeric GitHub ID. The sync updates name, handle, displayName, and image when changes are detected.

  • Scheduled via ctx.scheduler.runAfter(0, ...) to avoid blocking sign-in flow
  • Uses existing requireGitHubAccountAge pattern for API calls with proper error handling
  • Best-effort sync that fails silently if GitHub API is unavailable
  • Only updates when username actually changes (prevents unnecessary writes)

Confidence Score: 4/5

  • This PR is safe to merge with minor risk
  • The implementation follows established patterns in the codebase and handles edge cases well (deleted users, API failures). However, there is one logical error in the displayName update logic that should be fixed before merging to ensure correct behavior when users have customized their display name to match their handle.
  • Pay close attention to convex/users.ts - the displayName update logic needs correction

Last reviewed commit: 19ec3e7

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/311 **Author:** [@ianalloway](https://github.com/ianalloway) **Created:** 2/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (6) - [`3f4bb8f`](https://github.com/openclaw/clawhub/commit/3f4bb8f6a23aaef34b72ddb7480aaa7e63b0d7f5) fix: sync GitHub profile on login to handle username renames (#303) - [`19ec3e7`](https://github.com/openclaw/clawhub/commit/19ec3e79217067bbf577367dc543345e6b7d9181) Merge pull request #1 from ianalloway/devin/1771109978-fix-github-username-sync - [`7ab1862`](https://github.com/openclaw/clawhub/commit/7ab186234948b071ccb91e7c2c84ce44e17edc98) fix: allow updating skill summary/description on subsequent publishes (#301) - [`36078ad`](https://github.com/openclaw/clawhub/commit/36078ad54ec065dddcef7a822568718b459a3469) Merge pull request #2 from ianalloway/devin/1771112524-skill-metadata-update - [`1d53b25`](https://github.com/openclaw/clawhub/commit/1d53b25aec6e5d1dc34e2a59e01a8e1c24b2a2f1) Merge branch 'main' into main - [`331ba0d`](https://github.com/openclaw/clawhub/commit/331ba0d705798c8a466bd321b862b388e0ff3afa) Update convex/users.ts ### 📊 Changes **2 files changed** (+16 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `convex/auth.ts` (+7 -0) 📝 `convex/lib/githubAccount.ts` (+9 -0) </details> ### 📄 Description ## Summary Fixes #303 - When a user renames their GitHub account, the stored username becomes stale and causes "GitHub account lookup failed" errors during skill publishing. This PR adds a background sync that runs on every login to keep the user's GitHub profile (username, avatar) up-to-date: 1. **`syncGitHubProfile`** - Fetches current profile from GitHub API using the immutable numeric user ID 2. **`syncGitHubProfileInternal`** - Mutation that updates `name`, `handle`, `displayName`, and `image` fields when the username changes 3. **Auth callback integration** - Schedules the sync as a background action via `ctx.scheduler.runAfter(0, ...)` so it doesn't block sign-in The sync is best-effort: if the GitHub API is unavailable, it logs a warning and continues silently. ## Changes - `convex/lib/githubAccount.ts`: Added `syncGitHubProfile` function - `convex/users.ts`: Added `syncGitHubProfileInternal` mutation and `syncGitHubProfileAction` internal action - `convex/auth.ts`: Integrated sync into `afterUserCreatedOrUpdated` callback <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Added background GitHub profile sync on login to handle username renames by fetching current profile data using the immutable numeric GitHub ID. The sync updates `name`, `handle`, `displayName`, and `image` when changes are detected. - Scheduled via `ctx.scheduler.runAfter(0, ...)` to avoid blocking sign-in flow - Uses existing `requireGitHubAccountAge` pattern for API calls with proper error handling - Best-effort sync that fails silently if GitHub API is unavailable - Only updates when username actually changes (prevents unnecessary writes) <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with minor risk - The implementation follows established patterns in the codebase and handles edge cases well (deleted users, API failures). However, there is one logical error in the `displayName` update logic that should be fixed before merging to ensure correct behavior when users have customized their display name to match their handle. - Pay close attention to `convex/users.ts` - the `displayName` update logic needs correction <sub>Last reviewed commit: 19ec3e7</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:54 -05:00
yindo closed this issue 2026-02-15 17:16:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#324