[GH-ISSUE #4174] auth.api.listUserAccounts return type field naming and type are inconsistent with usage in other areas #9850

Closed
opened 2026-04-13 05:37:06 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @SkepticMystic on GitHub (Aug 23, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4174

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

The return type of auth.api.listUserAccounts is a list of accounts belonging to the user. The provider field shows the providerId of the account, but isn't named as such. The type could possibly also be improved? Other areas of BetterAuth have a well-typed providerId field, instead of just a string

Current vs. Expected behavior

Change the name to providerId, and possibly narrow the string type to the actual providers

What version of Better Auth are you using?

1.3.7

System info

N/A

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)

N/A

Additional context

No response

Originally created by @SkepticMystic on GitHub (Aug 23, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4174 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce The return type of `auth.api.listUserAccounts` is a list of accounts belonging to the user. The `provider` field shows the providerId of the account, but isn't named as such. The type could possibly also be improved? Other areas of BetterAuth have a well-typed `providerId` field, instead of just a `string` ### Current vs. Expected behavior Change the name to `providerId`, and possibly narrow the string type to the actual providers ### What version of Better Auth are you using? 1.3.7 ### System info ```bash N/A ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript N/A ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 05:37:06 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 23, 2025):

Hi @SkepticMystic! I'm Dosu and I’m helping the better-auth team.

You're right—there's an inconsistency: auth.api.listUserAccounts returns accounts with a provider field (typed as a generic string), while other areas of Better Auth use providerId and often narrow its type to a union of supported provider strings for better type safety. The database schema, OAuth plugin configs, and API endpoints all consistently use providerId as the field name and type, which makes migration straightforward and beneficial for clarity and maintainability [docs].

To align with the rest of the codebase, consider renaming the field to providerId and using an existing provider ID type (such as a union of string literals or an enum) instead of a plain string. This will improve type safety and developer experience. There’s ongoing work to improve providerId type consistency in related areas, but this specific naming issue hasn’t been addressed yet [PR #3712].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3216711032 --> @dosubot[bot] commented on GitHub (Aug 23, 2025): <!-- Greeting --> Hi @SkepticMystic! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> You're right—there's an inconsistency: `auth.api.listUserAccounts` returns accounts with a `provider` field (typed as a generic string), while other areas of Better Auth use `providerId` and often narrow its type to a union of supported provider strings for better type safety. The database schema, OAuth plugin configs, and API endpoints all consistently use `providerId` as the field name and type, which makes migration straightforward and beneficial for clarity and maintainability [[docs](https://better-auth.com/docs/concepts/database)]. To align with the rest of the codebase, consider renaming the field to `providerId` and using an existing provider ID type (such as a union of string literals or an enum) instead of a plain string. This will improve type safety and developer experience. There’s ongoing work to improve providerId type consistency in related areas, but this specific naming issue hasn’t been addressed yet [[PR #3712](https://github.com/better-auth/better-auth/pull/3712)]. <!-- 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/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/202c0b00-6582-475c-9948-17a5c7c7d4ec?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&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/4174)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9850