Add fillMissingUserInfoOnLink option for selective field updates when linking accounts #1916

Open
opened 2026-03-13 09:12:32 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Maxime-RiseVerse on GitHub (Sep 13, 2025).

Is this suited for github?

  • Yes, this is suited for github

I'm always frustrated when linking accounts doesn't fill in missing profile information.
When updateUserInfoOnLink is enabled, it overwrites ALL fields even if they already have values.
When it's disabled, it doesn't update anything at all. There's no middle ground.

For example: A user signs up with email/password (no image), then later links their Google account.
Their Google profile image doesn't get added because updateUserInfoOnLink is risky to enable (it would overwrite existing data).

Current code in packages/better-auth/src/api/routes/account.ts:

// This overwrites everything, no matter what
await c.context.internalAdapter.updateUser(session.user.id, {
    name: linkingUserInfo.user?.name,
    image: linkingUserInfo.user?.image,
});

Describe the solution you'd like

Add fillMissingUserInfoOnLink option that only fills empty fields:

export const auth = betterAuth({
  account: {
    accountLinking: {
      fillMissingUserInfoOnLink: true // Only update null/empty fields
    }
  }
});

Simple implementation:

const currentUser = await c.context.internalAdapter.findUserById(session.user.id);
const updates = {};

// Only add if field is empty
if (!currentUser.name && linkingUserInfo.user?.name) {
    updates.name = linkingUserInfo.user.name;
}
if (!currentUser.image && linkingUserInfo.user?.image) {
    updates.image = linkingUserInfo.user.image;
}

if (Object.keys(updates).length > 0) {
    await c.context.internalAdapter.updateUser(session.user.id, updates);
}

Describe alternatives you've considered

  1. Keep using updateUserInfoOnLink – Risk overwriting user data
  2. Manual database hooks – Every project needs custom code
  3. Do nothing – Users have incomplete profiles

Additional context

Common scenario: User signs up with email, has no profile image.
Links Google account later, still no image because we can't safely enable updateUserInfoOnLink.

With fillMissingUserInfoOnLink, the Google profile image would be added without overwriting any existing data.

Originally created by @Maxime-RiseVerse on GitHub (Sep 13, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I'm always frustrated when linking accounts doesn't fill in missing profile information. When updateUserInfoOnLink is enabled, it overwrites ALL fields even if they already have values. When it's disabled, it doesn't update anything at all. There's no middle ground. For example: A user signs up with email/password (no image), then later links their Google account. Their Google profile image doesn't get added because updateUserInfoOnLink is risky to enable (it would overwrite existing data). Current code in packages/better-auth/src/api/routes/account.ts: ``` // This overwrites everything, no matter what await c.context.internalAdapter.updateUser(session.user.id, { name: linkingUserInfo.user?.name, image: linkingUserInfo.user?.image, }); ``` ### Describe the solution you'd like Add fillMissingUserInfoOnLink option that only fills empty fields: ``` export const auth = betterAuth({ account: { accountLinking: { fillMissingUserInfoOnLink: true // Only update null/empty fields } } }); ``` Simple implementation: ``` const currentUser = await c.context.internalAdapter.findUserById(session.user.id); const updates = {}; // Only add if field is empty if (!currentUser.name && linkingUserInfo.user?.name) { updates.name = linkingUserInfo.user.name; } if (!currentUser.image && linkingUserInfo.user?.image) { updates.image = linkingUserInfo.user.image; } if (Object.keys(updates).length > 0) { await c.context.internalAdapter.updateUser(session.user.id, updates); } ``` ### Describe alternatives you've considered 1. Keep using updateUserInfoOnLink – Risk overwriting user data 2. Manual database hooks – Every project needs custom code 3. Do nothing – Users have incomplete profiles ### Additional context Common scenario: User signs up with email, has no profile image. Links Google account later, still no image because we can't safely enable updateUserInfoOnLink. With fillMissingUserInfoOnLink, the Google profile image would be added without overwriting any existing data.
GiteaMirror added the enhancement label 2026-03-13 09:12:32 -05:00
Author
Owner

@Maxime-RiseVerse commented on GitHub (Dec 4, 2025):

@dosu Are there any open issues related to fillMissingUserInfoOnLink or selectively updating user fields during account linking? I want to close this if it's a duplicate.

@Maxime-RiseVerse commented on GitHub (Dec 4, 2025): @dosu Are there any open issues related to fillMissingUserInfoOnLink or selectively updating user fields during account linking? I want to close this if it's a duplicate.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 4, 2025):

I checked for open issues and discussions related to fillMissingUserInfoOnLink or selective user field updates during account linking. There are several related threads—like #1476 (Google OAuth not importing profile image), #4218 (limitations in account linking flows), #2172 (email requirements during linking), #4180 (merging user data on link), and discussion #2733 (what happens to user fields when linking)—but none of them propose or track a fillMissingUserInfoOnLink option or the specific behavior you described.

No duplicate exists, so you’re good to proceed with your feature request. I searched using keywords like "fillMissingUserInfoOnLink", "account linking", and "selective update" to confirm.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 4, 2025): <!-- Answer --> I checked for open issues and discussions related to `fillMissingUserInfoOnLink` or selective user field updates during account linking. There are several related threads—like [#1476](https://github.com/better-auth/better-auth/issues/1476) (Google OAuth not importing profile image), [#4218](https://github.com/better-auth/better-auth/issues/4218) (limitations in account linking flows), [#2172](https://github.com/better-auth/better-auth/issues/2172) (email requirements during linking), [#4180](https://github.com/better-auth/better-auth/issues/4180) (merging user data on link), and [discussion #2733](https://github.com/better-auth/better-auth/discussions/2733) (what happens to user fields when linking)—but none of them propose or track a `fillMissingUserInfoOnLink` option or the specific behavior you described. No duplicate exists, so you’re good to proceed with your feature request. I searched using keywords like "fillMissingUserInfoOnLink", "account linking", and "selective update" to confirm. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/49e06d61-0a5f-453b-b180-4f48a3d0775d?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=I%20checked%20for%20open%20issues%20and%20discussions%20related%20to%20%60fillMissingUserInfoOnLink%60%20or%20selective%20user%20field%20updates%20during%20account%20linking.%20There%20are%20several%20related%20threads%E2%80%94like%20%5B%231476%5D%28https%3A//github.com/better-auth/better-auth/issues/1476%29%20%28Google%20OAuth%20not%20importing%20profile%20image%29%2C%20%5B%234218%5D%28https%3A//github.com/better-auth/better-auth/issues/4218%29%20%28limitations%20in%20account%20linking%20flows%29%2C%20%5B%232172%5D%28https%3A//github.com/better-auth/better-auth/issues/2172%29%20%28email%20requirements%20during%20linking%29%2C%20%5B%234180%5D%28https%3A//github.com/better-auth/better-auth/issues/4180%29%20%28merging%20user%20data%20on%20link%29%2C%20and%20%5Bdiscussion%20%232733%5D%28https%3A//github.com/better-auth/better-auth/discussions/2733%29%20%28what%20happens%20to%20user%20fields%20when%20linking%29%E2%80%94but%20none%20of%20them%20propose%20or%20track%20a%20%60fillMissingUserInfoOnLink%60%20option%20or%20the%20specific%20behavior%20you%20described.%0A%0ANo%20duplicate%20exists%2C%20so%20you%E2%80%99re%20good%20to%20proceed%20with%20your%20feature%20request.%20I%20searched%20using%20keywords%20like%20%22fillMissingUserInfoOnLink%22%2C%20%22account%20linking%22%2C%20and%20%22selective%20update%22%20to%20confirm.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4628)
Author
Owner

@mmmmoj commented on GitHub (Dec 30, 2025):

Can't you use mapProfileToUser? with this feature, you may propagate user table with any gap data!

@mmmmoj commented on GitHub (Dec 30, 2025): Can't you use [mapProfileToUser](https://www.better-auth.com/docs/concepts/oauth#mapprofiletouser)? with this feature, you may propagate user table with any gap data!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1916