From 55fbe40152a368b6a7d507a3459ee18f585c09ea Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 31 Jul 2025 16:13:39 +0200 Subject: [PATCH] fix(api): more informative auth errors (#61607) --- api/src/plugins/auth0.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/src/plugins/auth0.ts b/api/src/plugins/auth0.ts index 515408e92f3..6051aa018d1 100644 --- a/api/src/plugins/auth0.ts +++ b/api/src/plugins/auth0.ts @@ -4,6 +4,7 @@ import { Type } from '@sinclair/typebox'; import { Value } from '@sinclair/typebox/value'; import fp from 'fastify-plugin'; +import { isError } from 'lodash'; import { API_LOCATION, AUTH0_CLIENT_ID, @@ -151,7 +152,14 @@ export const auth0Client: FastifyPluginCallbackTypebox = fp( } } catch (error) { logger.error(error, 'Failed to get userinfo from Auth0'); - fastify.Sentry.captureException(error); + if (isError(error) && 'innerError' in error) { + // This is a specific error from the @fastify/oauth2 plugin. + const innerError = error.innerError as Error; + innerError.message = `Auth0 userinfo error: ${innerError.message}`; + fastify.Sentry.captureException(error.innerError); + } else { + fastify.Sentry.captureException(error); + } return reply.redirectWithMessage(returnTo, { type: 'danger', content: 'flash.generic-error'