From 235c0ad39bcee7209c280bb9b7d9be5523d1851c Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Fri, 3 Jul 2026 22:52:39 +0200 Subject: [PATCH] fix(attachment-counts api): surface real error details instead of generic PB admin message capture the thrown error, extract its message if available, and append it to the base "PB admin unavailable" error response. fall back to a generic unknown error message for non-Error failures, revealing actionable debugging details like missing env vars or invalid PB credentials. --- src/app/api/v1/sprint/attachment-counts/route.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/api/v1/sprint/attachment-counts/route.ts b/src/app/api/v1/sprint/attachment-counts/route.ts index 9b34937..9f12907 100644 --- a/src/app/api/v1/sprint/attachment-counts/route.ts +++ b/src/app/api/v1/sprint/attachment-counts/route.ts @@ -42,9 +42,14 @@ export async function GET(req: NextRequest) { let adminPb; try { adminPb = await getAdminPocketBase(); - } catch { + } catch (err) { + // Surface the real reason — the generic "PB admin unavailable" + // message was hiding the actual cause (missing env var, wrong + // password, PB unreachable from the prod container, etc.). + const reason = + err instanceof Error ? err.message : "unknown admin error"; return NextResponse.json( - { error: "PB admin unavailable" }, + { error: `PB admin unavailable: ${reason}` }, { status: 500 }, ); }