🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): stop capturing expected auth-flow outcomes as Sentry errors (#15819)
Nikita Kabardin129cf9aecad2
diff --git a/web/src/__tests__/auth-error-page.clienttest.tsx b/web/src/__tests__/auth-error-page.clienttest.tsxnew file mode 100644index 0000000000..04261eeb49--- /dev/null+++ b/web/src/__tests__/auth-error-page.clienttest.tsx@@ -0,0 +1,82 @@+import { render } from "@testing-library/react";++import AuthError from "@/src/pages/auth/error";+import { MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE } from "@/src/features/auth/constants";++const { captureExceptionMock, addBreadcrumbMock, routerState } = vi.hoisted(+ () => ({+ captureExceptionMock: vi.fn(),+ addBreadcrumbMock: vi.fn(),+ routerState: { query: {} as Record<string, string> },+ }),+);++vi.mock("@sentry/nextjs", () => ({+ captureException: captureExceptionMock,+ addBreadcrumb: addBreadcrumbMock,+}));++vi.mock("next-auth/react", () => ({+ useSession: () => ({ status: "unauthenticated" }),+}));++vi.mock("next/router", () => ({+ useRouter: () => ({+ asPath: "/auth/error",+ query: routerState.query,+ push: vi.fn(),+ }),+}));++describe("/auth/error Sentry classification", () => {+ let warnSpy: ReturnType<typeof vi.spyOn>;++ beforeEach(() => {+ captureExceptionMock.mockClear();+ addBreadcrumbMock.mockClear();+ routerState.query = {};+ warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});+ });++ afterEach(() => {+ warnSpy.mockRestore();+ });++ it("does not capture an expired/used magic link (Verification)", () => {+ routerState.query = { error: "Verification" };+ render(<AuthError />);++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ });++ it("does not capture the deliberate SSO domain rejection", () => {+ routerState.query = { error: MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE };+ render(<AuthError />);++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ });++ // Negative fixtures: a genuine auth-system failure still captures.+ it.each(["Configuration", "AccessDenied", "Unknown provider explosion"])(+ "still captures %j",+ (error) => {+ routerState.query = { error };+ render(<AuthError />);++ expect(captureExceptionMock).toHaveBeenCalledTimes(1);+ const [err, options] = captureExceptionMock.mock.calls[0]!;+ expect(err.message).toBe(+ `ErrorPageWithSentry rendered: Authentication Error, ${error}`,+ );+ expect(options.tags.area).toBe("error-page");+ },+ );++ it("still captures when no error param is present (unknown state)", () => {+ render(<AuthError />);++ expect(captureExceptionMock).toHaveBeenCalledTimes(1);+ });+});diff --git a/web/src/__tests__/auth-sign-in-page.clienttest.tsx b/web/src/__tests__/auth-sign-in-page.clienttest.tsxnew file mode 100644index 0000000000..0964e33048--- /dev/null+++ b/web/src/__tests__/auth-sign-in-page.clienttest.tsx@@ -0,0 +1,185 @@+import { fireEvent, render, screen, waitFor } from "@testing-library/react";++import SignIn, { type PageProps } from "@/src/pages/auth/sign-in";++const { captureExceptionMock, addBreadcrumbMock, signInMock, routerState } =+ vi.hoisted(() => ({+ captureExceptionMock: vi.fn(),+ addBreadcrumbMock: vi.fn(),+ signInMock: vi.fn(),+ routerState: { query: {} as Record<string, string> },+ }));++vi.mock("@sentry/nextjs", () => ({+ captureException: captureExceptionMock,+ addBreadcrumb: addBreadcrumbMock,+}));++vi.mock("next-auth/react", () => ({+ signIn: signInMock,+ useSession: () => ({ status: "unauthenticated", data: null }),+}));++vi.mock("next/router", () => ({+ useRouter: () => ({+ asPath: "/auth/sign-in",+ query: routerState.query,+ push: vi.fn(),+ replace: vi.fn(),+ }),+}));++vi.mock("@/src/env.mjs", () => ({ env: {} }));++vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({+ usePostHogClientCapture: () => vi.fn(),+}));++vi.mock("@/src/features/organizations/hooks", () => ({+ useLangfuseCloudRegion: () => ({+ isLangfuseCloud: false,+ region: undefined,+ }),+}));++vi.mock("@/src/ee/features/multi-tenant-sso/utils", () => ({+ isAnySsoConfigured: async () => false,+}));++vi.mock("@/src/features/auth/components/AuthCloudRegionSwitch", () => ({+ CloudRegionSwitch: () => null,+}));++vi.mock("@/src/features/auth/components/AuthCloudPrivacyNotice", () => ({+ CloudPrivacyNotice: () => null,+}));++const authProviders: PageProps["authProviders"] = {+ credentials: true,+ google: false,+ github: false,+ githubEnterprise: false,+ gitlab: false,+ okta: false,+ authentik: false,+ onelogin: false,+ azureAd: false,+ auth0: false,+ clickhouseCloud: false,+ cognito: false,+ keycloak: false,+ workos: false,+ wordpress: false,+ custom: false,+ sso: false,+};++const renderSignIn = (+ props: Partial<PageProps> & {+ authProviders?: PageProps["authProviders"];+ } = {},+) =>+ render(+ <SignIn+ authProviders={authProviders}+ signUpDisabled={false}+ runningOnHuggingFaceSpaces={false}+ emailVerificationRequired={false}+ {...props}+ />,+ );++describe("sign-in page NextAuth error classification", () => {+ let warnSpy: ReturnType<typeof vi.spyOn>;++ beforeEach(() => {+ captureExceptionMock.mockClear();+ addBreadcrumbMock.mockClear();+ signInMock.mockReset();+ routerState.query = {};+ window.localStorage.clear();+ warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});+ });++ afterEach(() => {+ warnSpy.mockRestore();+ });++ it("breadcrumbs an allowlisted code (OAuthCallback) instead of capturing", () => {+ routerState.query = { error: "OAuthCallback" };+ renderSignIn();++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ const crumb = addBreadcrumbMock.mock.calls[0]![0];+ expect(crumb.category).toBe("auth.signIn");+ expect(crumb.data).toEqual({ code: "OAuthCallback" });+ });++ it("breadcrumbs a mapped code (OAuthAccountNotLinked) instead of capturing", () => {+ routerState.query = { error: "OAuthAccountNotLinked" };+ renderSignIn();++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ });++ it("breadcrumbs an IdP-described error instead of capturing", () => {+ routerState.query = {+ error: "some_idp_error",+ error_description: "User did not grant access",+ };+ renderSignIn();++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ });++ // Negative fixtures: codes outside the allowlist are real errors.+ it.each(["OAuthSignin", "Configuration", "SomeUnknownCode"])(+ "still captures %j",+ (error) => {+ routerState.query = { error };+ renderSignIn();++ expect(captureExceptionMock).toHaveBeenCalledTimes(1);+ const [err, options] = captureExceptionMock.mock.calls[0]!;+ expect(err.message).toBe(`Sign in error: ${error}`);+ expect(options.tags.area).toBe("auth.signIn");+ expect(addBreadcrumbMock).not.toHaveBeenCalled();+ },+ );++ it("treats an undefined signIn() result as an expected transport blip", async () => {+ signInMock.mockResolvedValue(undefined);+ renderSignIn();++ fireEvent.change(screen.getByLabelText("Email"), {+ target: { value: "[email protected]" },+ });+ fireEvent.change(screen.getByLabelText(/Password/), {+ target: { value: "password123" },+ });+ fireEvent.click(screen.getByTestId("submit-email-password-sign-in-form"));++ await waitFor(() => {+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ });+ expect(addBreadcrumbMock.mock.calls[0]![0].category).toBe(+ "auth.signIn.credentials",+ );+ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(+ screen.getByText(/An unexpected error occurred/),+ ).toBeInTheDocument();+ });++ it("renders without crashing when props are missing (fallback providers)", () => {+ renderSignIn({+ authProviders: undefined as unknown as PageProps["authProviders"],+ });++ expect(screen.getByText("Sign in to your account")).toBeInTheDocument();+ expect(captureExceptionMock).not.toHaveBeenCalled();+ });+});diff --git a/web/src/components/error-page.clienttest.tsx b/web/src/components/error-page.clienttest.tsxnew file mode 100644index 0000000000..c43b6a8eec--- /dev/null+++ b/web/src/components/error-page.clienttest.tsx@@ -0,0 +1,81 @@+import { render, screen } from "@testing-library/react";++import { ErrorPageWithSentry } from "@/src/components/error-page";++const { captureExceptionMock, addBreadcrumbMock } = vi.hoisted(() => ({+ captureExceptionMock: vi.fn(),+ addBreadcrumbMock: vi.fn(),+}));++vi.mock("@sentry/nextjs", () => ({+ captureException: captureExceptionMock,+ addBreadcrumb: addBreadcrumbMock,+}));++vi.mock("next-auth/react", () => ({+ useSession: () => ({ status: "unauthenticated" }),+}));++vi.mock("next/router", () => ({+ useRouter: () => ({ asPath: "/auth/error", query: {}, push: vi.fn() }),+}));++describe("ErrorPageWithSentry", () => {+ let warnSpy: ReturnType<typeof vi.spyOn>;++ beforeEach(() => {+ captureExceptionMock.mockClear();+ addBreadcrumbMock.mockClear();+ warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});+ });++ afterEach(() => {+ warnSpy.mockRestore();+ });++ it("captures a real Error with the error-page area by default", () => {+ render(<ErrorPageWithSentry title="Some Error" message="It broke" />);++ expect(captureExceptionMock).toHaveBeenCalledTimes(1);+ const [err, options] = captureExceptionMock.mock.calls[0]!;+ expect(err).toBeInstanceOf(Error);+ expect(err.message).toBe(+ "ErrorPageWithSentry rendered: Some Error, It broke",+ );+ expect(options.tags.area).toBe("error-page");+ expect(addBreadcrumbMock).not.toHaveBeenCalled();+ });++ it("breadcrumbs instead of capturing when the outcome is expected", () => {+ render(+ <ErrorPageWithSentry+ title="Authentication Error"+ message="Verification"+ expected+ />,+ );++ expect(captureExceptionMock).not.toHaveBeenCalled();+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);+ const crumb = addBreadcrumbMock.mock.calls[0]![0];+ expect(crumb.category).toBe("error-page");+ expect(crumb.data).toEqual({+ title: "Authentication Error",+ message: "Verification",+ });+ });++ it("renders the same UX either way", () => {+ render(+ <ErrorPageWithSentry+ title="Authentication Error"+ message="Verification"+ expected+ />,+ );++ expect(screen.getByText("Authentication Error")).toBeInTheDocument();+ expect(screen.getByText("Verification")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Sign In" })).toBeInTheDocument();+ });+});diff --git a/web/src/components/error-page.tsx b/web/src/components/error-page.tsxindex ae80e12ec6..b1d1b07dd3 100644--- a/web/src/components/error-page.tsx+++ b/web/src/components/error-page.tsx@@ -66,6 +66,7 @@ export const ErrorPageWithSentry = ({title = "Error",message,additionalButton,+ expected = false,}: {title?: string;message: string;@@ -78,15 +79,17 @@ export const ErrorPageWithSentry = ({label: string;onClick: () => void;};+ /** Expected, user-caused outcome: breadcrumb instead of a Sentry error. */+ expected?: boolean;}) => {useEffect(() => {- // Capture the error with Sentry+ // Capture the error with Sentry (breadcrumb only when expected)if (window !== undefined)reportError(new Error(`ErrorPageWithSentry rendered: ${title}, ${message}`),- { area: "error-page" },+ { area: "error-page", expected, extra: { title, message } },);- }, [title, message]); // Empty dependency array means this effect runs once on mount+ }, [title, message, expected]);return (<ErrorPagediff --git a/web/src/features/auth/constants.ts b/web/src/features/auth/constants.tsindex dfee99a4eb..f1eae78827 100644--- a/web/src/features/auth/constants.ts+++ b/web/src/features/auth/constants.ts@@ -1,2 +1,9 @@export const ENTERPRISE_SSO_REQUIRED_MESSAGE ="You must sign in via custom Enterprise SSO for this domain. Enter your email on the sign-in page and press Continue.";++// Thrown by the NextAuth signIn callback (web/src/server/auth.ts) when a+// multi-tenant SSO provider is used with an email of a different domain.+// NextAuth redirects the thrown message verbatim to /auth/error?error=<message>,+// where it is matched to classify the render as an expected outcome.+export const MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE =+ "This domain is not associated with this SSO provider.";diff --git a/web/src/features/auth/lib/expectedAuthErrors.clienttest.ts b/web/src/features/auth/lib/expectedAuthErrors.clienttest.tsnew file mode 100644index 0000000000..037b12013b--- /dev/null+++ b/web/src/features/auth/lib/expectedAuthErrors.clienttest.ts@@ -0,0 +1,72 @@+import {+ isExpectedSignInError,+ isExpectedAuthErrorPageMessage,+} from "@/src/features/auth/lib/expectedAuthErrors";+import { MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE } from "@/src/features/auth/constants";++describe("expectedAuthErrors", () => {+ describe("isExpectedSignInError", () => {+ it.each(["OAuthCallback", "Callback"])(+ "classifies %s as expected (user-caused / provider-transient)",+ (code) => {+ expect(isExpectedSignInError(code)).toBe(true);+ },+ );++ // Negative fixtures: codes that indicate misconfiguration or genuine+ // failures must stay captured. An unknown code is never expected.+ it.each([+ "OAuthSignin", // authorization-URL construction failed → misconfig+ "OAuthCreateAccount", // DB user creation failed+ "EmailCreateAccount",+ "EmailSignin", // verification email failed to send+ "Signin",+ "Configuration",+ "SessionRequired",+ "CredentialsSignin",+ "credentials", // observed unknown string, must capture+ "acme.com.azure-ad", // provider-id-shaped unknown string, must capture+ "",+ ])("keeps %j captured", (code) => {+ expect(isExpectedSignInError(code)).toBe(false);+ });++ it("is case-sensitive (a mangled code is an unknown code)", () => {+ expect(isExpectedSignInError("oauthcallback")).toBe(false);+ });+ });++ describe("isExpectedAuthErrorPageMessage", () => {+ it("classifies Verification (expired/used magic link) as expected", () => {+ expect(isExpectedAuthErrorPageMessage("Verification")).toBe(true);+ });++ it("classifies the deliberate SSO domain rejection as expected", () => {+ expect(+ isExpectedAuthErrorPageMessage(+ MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE,+ ),+ ).toBe(true);+ });++ // Negative fixtures: real auth-system failures must stay captured.+ it.each([+ "Configuration", // server misconfiguration+ "AccessDenied",+ "Default",+ "undefined", // observed literal-string artifact, must capture+ "Some unexpected IdP failure",+ "",+ ])("keeps %j captured", (message) => {+ expect(isExpectedAuthErrorPageMessage(message)).toBe(false);+ });++ it("matches the full message only (no substring matching)", () => {+ expect(+ isExpectedAuthErrorPageMessage(+ `prefix ${MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE}`,+ ),+ ).toBe(false);+ });+ });+});diff --git a/web/src/features/auth/lib/expectedAuthErrors.ts b/web/src/features/auth/lib/expectedAuthErrors.tsnew file mode 100644index 0000000000..50e6dead03--- /dev/null+++ b/web/src/features/auth/lib/expectedAuthErrors.ts@@ -0,0 +1,49 @@+import { MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE } from "@/src/features/auth/constants";++/**+ * Classify NextAuth error outcomes surfaced in the browser+ * (https://next-auth.js.org/configuration/pages).+ *+ * Allowlisted values are user-caused or provider-transient outcomes the UI+ * already renders — they breadcrumb instead of capturing (see `reportError`).+ * Every server-actionable variant of these failures is logged server-side by+ * NextAuth through `nextAuthLogger` (`[NEXT_AUTH] OAUTH_CALLBACK_ERROR`, …),+ * so a systemic auth breakage stays visible without the client copy.+ * Anything NOT listed here still captures: an explicit allowlist, never a+ * catch-all.+ */++// Sign-in page `?error=` codes (next-auth v4 redirects these to pages.signIn):+// - OAuthCallback: user cancelled at the provider, expired/mismatched state+// cookie, or a provider hiccup during the token exchange. Server-side,+// next-auth logs `OAUTH_CALLBACK_ERROR` before issuing this redirect.+// - Callback: error thrown in the callback route; always preceded by a+// server-side `OAUTH_CALLBACK_ERROR` / `OAUTH_CALLBACK_HANDLER_ERROR` /+// `CALLBACK_EMAIL_ERROR` log.+// Deliberately NOT listed (still capture): OAuthSignin (authorization-URL+// construction = provider misconfig), OAuthCreateAccount / EmailCreateAccount+// (DB failures), EmailSignin (verification email failed to send), Signin,+// Configuration, and any unknown/custom string.+export const EXPECTED_SIGN_IN_ERROR_CODES: readonly string[] = [+ "OAuthCallback",+ "Callback",+];++export const isExpectedSignInError = (code: string): boolean =>+ EXPECTED_SIGN_IN_ERROR_CODES.includes(code);++// /auth/error `?error=` values:+// - Verification: the magic-link token expired or was already used. NextAuth+// emits this value only for the clean invalid-token outcome — infra failures+// in the same flow throw and take the server-logged error paths instead, so+// this value is user-caused by construction.+// - SSO domain mismatch: deliberate rejection thrown by our signIn callback+// (logged server-side before the throw).+// Configuration / AccessDenied / unknown values still capture.+export const EXPECTED_AUTH_ERROR_PAGE_MESSAGES: readonly string[] = [+ "Verification",+ MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE,+];++export const isExpectedAuthErrorPageMessage = (message: string): boolean =>+ EXPECTED_AUTH_ERROR_PAGE_MESSAGES.includes(message);diff --git a/web/src/pages/auth/error.tsx b/web/src/pages/auth/error.tsxindex d0fd488861..e02fcf48eb 100644--- a/web/src/pages/auth/error.tsx+++ b/web/src/pages/auth/error.tsx@@ -1,4 +1,5 @@import { ErrorPageWithSentry } from "@/src/components/error-page";+import { isExpectedAuthErrorPageMessage } from "@/src/features/auth/lib/expectedAuthErrors";import { useRouter } from "next/router";export default function AuthError() {@@ -9,6 +10,14 @@ export default function AuthError() {: "An authentication error occurred. Please reach out to support.";return (- <ErrorPageWithSentry title="Authentication Error" message={errorMessage} />+ <ErrorPageWithSentry+ title="Authentication Error"+ message={errorMessage}+ // Expired magic links and deliberate SSO-domain rejections are expected+ // outcomes (see expectedAuthErrors.ts); unknown values still capture.+ expected={+ error !== undefined && isExpectedAuthErrorPageMessage(errorMessage)+ }+ />);}diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsxindex e9cfc9e4d2..ddf22b5791 100644--- a/web/src/pages/auth/sign-in.tsx+++ b/web/src/pages/auth/sign-in.tsx@@ -39,6 +39,7 @@ import { isEmailVerificationRequired } from "@/src/features/auth-credentials/libimport { Code, Key } from "lucide-react";import { useRouter } from "next/router";import { reportError } from "@/src/utils/reportError";+import { isExpectedSignInError } from "@/src/features/auth/lib/expectedAuthErrors";import { captureUnknownError } from "@/src/utils/captureUnknownError";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useLocalStorage from "@/src/components/useLocalStorage";@@ -193,6 +194,30 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async () => {};};+// A client-side navigation whose props fetch fails (e.g. deploy skew) can+// mount the page with empty props despite the PageProps contract — fall back+// to "no providers" instead of crashing on `authProviders.sso`.+// Also used in src/pages/auth/sign-up.tsx+export const FALLBACK_AUTH_PROVIDERS: PageProps["authProviders"] = {+ credentials: false,+ google: false,+ github: false,+ githubEnterprise: false,+ gitlab: false,+ okta: false,+ authentik: false,+ onelogin: false,+ azureAd: false,+ auth0: false,+ clickhouseCloud: false,+ cognito: false,+ keycloak: false,+ workos: false,+ wordpress: false,+ custom: false,+ sso: false,+};+type NextAuthProvider = NonNullable<Parameters<typeof signIn>[0]>;// Also used in src/pages/auth/sign-up.tsx@@ -541,7 +566,7 @@ const signInErrors = [];export default function SignIn({- authProviders,+ authProviders = FALLBACK_AUTH_PROVIDERS,signUpDisabled,runningOnHuggingFaceSpaces,}: PageProps) {@@ -565,17 +590,20 @@ export default function SignIn({nextAuthError);useEffect(() => {- // log unexpected sign in errors to Sentry- // An error is unexpected if it's not in our mapped errors and has no IdP error_description- if (- nextAuthError &&- !nextAuthErrorDescription &&- !signInErrors.find((e) => e.code === nextAuthError)- ) {- reportError(new Error(`Sign in error: ${nextAuthError}`), {- area: "auth.signIn",- });- }+ if (!nextAuthError) return;+ // Expected = user-caused or provider-transient outcomes the form already+ // renders: mapped codes, allowlisted codes (expectedAuthErrors.ts), and+ // IdP-described errors. They breadcrumb instead of capturing; anything+ // else (unknown codes, misconfig codes) is a real Sentry error.+ const expected =+ Boolean(nextAuthErrorDescription) ||+ signInErrors.some((e) => e.code === nextAuthError) ||+ isExpectedSignInError(nextAuthError);+ reportError(new Error(`Sign in error: ${nextAuthError}`), {+ area: "auth.signIn",+ expected,+ extra: { code: nextAuthError },+ });}, [nextAuthError, nextAuthErrorDescription]);const [credentialsFormError, setCredentialsFormError] = useState<@@ -636,9 +664,15 @@ export default function SignIn({redirect: false,});if (result === undefined) {+ // next-auth's signIn() returns undefined when its providers fetch+ // failed (network drop, or the auth API unreachable/5xx — a transport+ // or server state the server owns, not an app failure here). It then+ // navigates to the error page itself; when the server is up, that+ // lands on /auth/error?error=undefined, which still captures.setCredentialsFormError("An unexpected error occurred.");reportError(new Error("Sign in result is undefined"), {area: "auth.signIn.credentials",+ expected: true,});} else if (!result.ok) {if (!result.error) {diff --git a/web/src/pages/auth/sign-up.tsx b/web/src/pages/auth/sign-up.tsxindex ddf8993c7d..17b00b1b11 100644--- a/web/src/pages/auth/sign-up.tsx+++ b/web/src/pages/auth/sign-up.tsx@@ -21,6 +21,7 @@ import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/Langfuimport { CloudPrivacyNotice } from "@/src/features/auth/components/AuthCloudPrivacyNotice";import { CloudRegionSwitch } from "@/src/features/auth/components/AuthCloudRegionSwitch";import {+ FALLBACK_AUTH_PROVIDERS,SSOButtons,useHuggingFaceRedirect,type PageProps,@@ -52,7 +53,7 @@ const signupVerifyFormSchema = z.object({type SignupPhase = "form" | "otp";export default function SignUp({- authProviders,+ authProviders = FALLBACK_AUTH_PROVIDERS,runningOnHuggingFaceSpaces,emailVerificationRequired,}: PageProps) {diff --git a/web/src/server/auth.ts b/web/src/server/auth.tsindex 8bbcc91e6d..b7209499b5 100644--- a/web/src/server/auth.ts+++ b/web/src/server/auth.ts@@ -47,7 +47,10 @@ import {getSsoAuthProviderIdForDomain,loadSsoProviders,} from "@/src/ee/features/multi-tenant-sso/utils";-import { ENTERPRISE_SSO_REQUIRED_MESSAGE } from "@/src/features/auth/constants";+import {+ ENTERPRISE_SSO_REQUIRED_MESSAGE,+ MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE,+} from "@/src/features/auth/constants";import { z } from "zod";import { CloudConfigSchema, projectRoleAccessRights } from "@langfuse/shared";import {@@ -1037,9 +1040,15 @@ export async function getAuthOptions(signupAttribution?: {isMultiTenantSsoProvider &&ssoDomain.toLowerCase() !== userDomain.toLowerCase()) {- throw new Error(- `This domain is not associated with this SSO provider.`,+ // warn: the ONLY server-side signal for this rejection — the+ // client render of the resulting /auth/error page is classified+ // as expected and not captured (expectedAuthErrors.ts), and+ // next-auth does not log signIn-callback throws itself.+ logger.warn(+ "Multi-tenant SSO provider used with a non-matching email domain",+ { email, attemptedProvider: account.provider },);+ throw new Error(MULTI_TENANT_SSO_DOMAIN_MISMATCH_MESSAGE);}}