Skip to content

fix: Throw ConfigurationError when invalid Auth0Client configuration #2026

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

Merged
merged 8 commits into from
Apr 3, 2025

Conversation

tusharpandey13
Copy link
Contributor

@tusharpandey13 tusharpandey13 commented Apr 2, 2025

This PR enhances the configuration validation in the Auth0Client class by adding a dedicated error class for configuration errors and improving error reporting.

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

  1. Added a new ConfigurationError class
  2. Added validation for required options for Auth0Client
  3. Added tests for the same
  4. Updated documentation

📎 References

🎯 Testing

PASSING

 Test Files  11 passed (11)
      Tests  174 passed (174)
   Start at  12:31:14
   Duration  803ms (transform 410ms, setup 0ms, collect 1.37s, tests 205ms, environment 1ms, prepare 509ms)

@tusharpandey13 tusharpandey13 requested a review from a team as a code owner April 2, 2025 07:08
@codecov-commenter
Copy link

codecov-commenter commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.65%. Comparing base (51deff0) to head (0f57478).

Files with missing lines Patch % Lines
src/errors/index.ts 92.00% 2 Missing ⚠️
src/server/client.ts 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2026      +/-   ##
==========================================
+ Coverage   74.82%   79.65%   +4.83%     
==========================================
  Files          21       21              
  Lines        1863     1922      +59     
  Branches      289      314      +25     
==========================================
+ Hits         1394     1531     +137     
+ Misses        462      385      -77     
+ Partials        7        6       -1     

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

@tusharpandey13 tusharpandey13 enabled auto-merge April 2, 2025 08:12
@tusharpandey13 tusharpandey13 force-pushed the feature/configuration-validation branch from 9d9f43f to 3c864e0 Compare April 2, 2025 08:49
nandan-bhat
nandan-bhat previously approved these changes Apr 2, 2025
@nandan-bhat nandan-bhat self-requested a review April 2, 2025 09:52
nandan-bhat
nandan-bhat previously approved these changes Apr 2, 2025
@tusharpandey13 tusharpandey13 dismissed frederikprijck’s stale review April 3, 2025 07:54

these review comments have been resolved

@frederikprijck frederikprijck mentioned this pull request Apr 3, 2025
@tusharpandey13 tusharpandey13 changed the title Feature: Auth0Client Configuration Validation Fix: Auth0Client Configuration Validation Apr 3, 2025
@frederikprijck frederikprijck changed the title Fix: Auth0Client Configuration Validation fix: Throw ConfigurationError when invalid Auth0Client configuration Apr 3, 2025
@tusharpandey13 tusharpandey13 merged commit 6370b96 into main Apr 3, 2025
12 checks passed
@tusharpandey13 tusharpandey13 deleted the feature/configuration-validation branch April 3, 2025 12:33
@ik-southpole
Copy link

Again breaking change... below was used to be a valid setup. We could run build and provide those envs in runtime. Now, build fails with the error.

import { Auth0Client } from "@auth0/nextjs-auth0/server";

const auth0 = new Auth0Client({
  domain: process.env.AUTH0_DOMAIN,
  secret: process.env.AUTH0_SECRET,
  appBaseUrl: process.env.APP_BASE_URL,
  clientId: process.env.AUTH0_CLIENT_ID,
  clientSecret: process.env.AUTH0_CLIENT_SECRET,
  authorizationParameters: { scope: "openid profile email offline_access" },
});

export default auth0;

@ik-southpole
Copy link

How to initialise Auth0Client with params provided in runtime (affected after updating from v4.4.0 to v4.4.1)?

@jgeurts
Copy link

jgeurts commented Apr 7, 2025

Like @ik-southpole mentioned, this caused a breaking change to us as well. Please use the proper semantic title for breaking changes.

@mdedys
Copy link

mdedys commented Apr 11, 2025

Again breaking change... below was used to be a valid setup. We could run build and provide those envs in runtime. Now, build fails with the error.

import { Auth0Client } from "@auth0/nextjs-auth0/server";

const auth0 = new Auth0Client({
  domain: process.env.AUTH0_DOMAIN,
  secret: process.env.AUTH0_SECRET,
  appBaseUrl: process.env.APP_BASE_URL,
  clientId: process.env.AUTH0_CLIENT_ID,
  clientSecret: process.env.AUTH0_CLIENT_SECRET,
  authorizationParameters: { scope: "openid profile email offline_access" },
});

export default auth0;

This is a breaking change for us as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants