Skip to content

Comments

Fix undefined providerId#12947

Merged
ThangHuuVu merged 9 commits intonextauthjs:mainfrom
Regloom:Regloom-patch-1
May 18, 2025
Merged

Fix undefined providerId#12947
ThangHuuVu merged 9 commits intonextauthjs:mainfrom
Regloom:Regloom-patch-1

Conversation

@Regloom
Copy link
Contributor

@Regloom Regloom commented May 9, 2025

☕️ Reasoning

Client-side auth with no providerId param results in error. Sample code:

import { signIn, signOut } from "@auth/sveltekit/client"
<button onclick={() => signIn()}>Sign In</button>

It's caused by parseActionAndProviderId function which returns providerId = "undefined" (as a string). This breaks the following check auth/core/src/lib/utils/providers.ts

export default function parseProviders(params) {
...
    if (providerId && !provider) {
        const availableProviders = providers.map((p) => p.id).join(", ");
        throw new Error(`Provider with id "${providerId}" not found. Available providers: [${availableProviders}].`);
    }
    return { providers, provider };
}

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Client-side auth with no `providerId` param results in error.
@Regloom Regloom requested a review from ThangHuuVu as a code owner May 9, 2025 12:23
@vercel
Copy link

vercel bot commented May 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2025 8:11am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview May 18, 2025 8:11am

@vercel
Copy link

vercel bot commented May 9, 2025

@Regloom is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@ThangHuuVu
Copy link
Member

thanks for the fix, could you add a test for it?

@Regloom
Copy link
Contributor Author

Regloom commented May 12, 2025

Ok, tests added.

@codecov
Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.19%. Comparing base (53b445f) to head (8488b4b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12947   +/-   ##
=======================================
  Coverage   39.18%   39.19%           
=======================================
  Files         200      200           
  Lines       31612    31615    +3     
  Branches     1374     1381    +7     
=======================================
+ Hits        12388    12391    +3     
  Misses      19224    19224           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ThangHuuVu ThangHuuVu merged commit dd211c5 into nextauthjs:main May 18, 2025
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Refers to `@auth/core`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants