From 2bdb1c75f680e7715bbe68c6f50e24ea861302ca Mon Sep 17 00:00:00 2001 From: Eugen Stan Date: Fri, 9 May 2025 14:27:06 +0300 Subject: [PATCH] fix(logs): log error cause when object, sign in oidc debug messages (#3054) Co-authored-by: Meier Lukas --- packages/auth/events.ts | 3 +++ packages/log/src/error.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/packages/auth/events.ts b/packages/auth/events.ts index 2c8c68dd7..7ca77e0f9 100644 --- a/packages/auth/events.ts +++ b/packages/auth/events.ts @@ -13,6 +13,7 @@ import { extractProfileName } from "./providers/oidc/oidc-provider"; export const createSignInEventHandler = (db: Database): Exclude["signIn"] => { return async ({ user, profile }) => { + logger.debug(`SignIn EventHandler for user: ${JSON.stringify(user)} . profile: ${JSON.stringify(profile)}`); if (!user.id) throw new Error("User ID is missing"); const dbUser = await db.query.users.findFirst({ @@ -28,11 +29,13 @@ export const createSignInEventHandler = (db: Database): Exclude { return `\ncaused by ${formatErrorTitle(cause)}\n${formatErrorStack(cause.stack)}${formatErrorCause(cause.cause, iteration + 1)}`; } + if (cause instanceof Object) { + return `\ncaused by ${JSON.stringify(cause)}`; + } + return `\ncaused by ${cause as string}`; };