From 581a20acd197d1176443981b7210bd411081e032 Mon Sep 17 00:00:00 2001 From: sax3l Date: Mon, 2 Nov 2026 16:32:55 +0100 Subject: [PATCH] chore(workbench): log the structure failure reason and source segment count Cloudflare replaces an origin 502 body with its own error page, so the JSON message never reached the client. Log the reason server-side (codes/messages only, never source text). --- app/api/0pt/documents/structure/route.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/api/0pt/documents/structure/route.ts b/app/api/0pt/documents/structure/route.ts index 51689f3..53ffe79 100644 --- a/app/api/0pt/documents/structure/route.ts +++ b/app/api/0pt/documents/structure/route.ts @@ -244,6 +244,7 @@ export async function POST(request: NextRequest) { ); } + console.log('[0pt-workbench] doc0 source read:', sources.sources.length, 'segments'); const sourceChars = sources.sources.reduce((total, source) => total + source.text.length, 0); const estimatedInputTokens = Math.ceil(JSON.stringify(sources.sources).length / 4) + 1024; if (estimatedInputTokens > policy.maxInputTokens) { @@ -433,6 +434,7 @@ export async function POST(request: NextRequest) { } } const message = error instanceof Error ? error.message : 'Structuring failed'; + console.error('[0pt-workbench] structure failed:', message); return NextResponse.json( { error: 'STRUCTURE_FAILED', message, reservation_id: reservationId }, { status: 502 }, -- 2.54.0