🪢 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): preserve decoded authentication error messages (#17835)
Luciend9c9d04e5b7c
diff --git a/web/src/features/auth/AuthErrorPage.clienttest.tsx b/web/src/features/auth/AuthErrorPage.clienttest.tsxnew file mode 100644index 0000000000..f6a9535fc1--- /dev/null+++ b/web/src/features/auth/AuthErrorPage.clienttest.tsx@@ -0,0 +1,38 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";++import AuthErrorPage from "@/src/features/auth/AuthErrorPage";++const { routerState } = vi.hoisted(() => ({+ routerState: { query: {} as Record<string, string> },+}));++vi.mock("next/router", () => ({+ useRouter: () => ({ query: routerState.query }),+}));++vi.mock("@/src/components/error-page", () => ({+ ErrorPageWithSentry: ({ message }: { message: string }) => <p>{message}</p>,+}));++describe("AuthErrorPage", () => {+ it("shows an error message containing a literal percent sign", () => {+ // Next.js has already decoded the query value once; decoding it again+ // throws on a bare `%`.+ routerState.query = { error: "Quota at 100% for this tenant" };++ render(<AuthErrorPage />);++ expect(+ screen.getByText("Quota at 100% for this tenant"),+ ).toBeInTheDocument();+ });++ it("shows an already-decoded percent sequence as is", () => {+ routerState.query = { error: "Value was %41" };++ render(<AuthErrorPage />);++ expect(screen.getByText("Value was %41")).toBeInTheDocument();+ });+});diff --git a/web/src/features/auth/AuthErrorPage.tsx b/web/src/features/auth/AuthErrorPage.tsxindex 2e452c0171..567a8a5ce9 100644--- a/web/src/features/auth/AuthErrorPage.tsx+++ b/web/src/features/auth/AuthErrorPage.tsx@@ -6,7 +6,7 @@ export default function AuthErrorPage() {const router = useRouter();const { error } = router.query;const errorMessage = error- ? decodeURIComponent(String(error))+ ? String(error): "An authentication error occurred. Please reach out to support.";return (diff --git a/web/src/features/auth/SignInPage.tsx b/web/src/features/auth/SignInPage.tsxindex 7d36e6ab29..2d7b34f210 100644--- a/web/src/features/auth/SignInPage.tsx+++ b/web/src/features/auth/SignInPage.tsx@@ -511,12 +511,10 @@ export default function SignInPage({// handle NextAuth error codes: https://next-auth.js.org/configuration/pages#sign-in-pageconst nextAuthError =- typeof router.query.error === "string"- ? decodeURIComponent(router.query.error)- : null;+ typeof router.query.error === "string" ? router.query.error : null;const nextAuthErrorDescription =typeof router.query.error_description === "string"- ? decodeURIComponent(router.query.error_description)+ ? router.query.error_description: null;// Use error_description from IdP if available, otherwise use mapped error or error code