Skip to content

Fix undefined providerId #12947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

Regloom
Copy link

@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
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 13, 2025 2:12am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview May 13, 2025 2:12am

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
Author

Regloom commented May 12, 2025

Ok, tests added.

Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@0adbd10). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12947   +/-   ##
=======================================
  Coverage        ?   39.19%           
=======================================
  Files           ?      200           
  Lines           ?    31615           
  Branches        ?     1382           
=======================================
  Hits            ?    12391           
  Misses          ?    19224           
  Partials        ?        0           

☔ 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.

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