From 328476a581982d07941d351182756b5aacc7b1e9 Mon Sep 17 00:00:00 2001 From: Marko Djordjevic Date: Wed, 18 Feb 2026 23:38:17 +0100 Subject: [PATCH] Fix predict proxy schema and error messages --- src/app/api/predict/route.ts | 4 ++-- src/app/page.tsx | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/api/predict/route.ts b/src/app/api/predict/route.ts index b66be5b..0c72985 100644 --- a/src/app/api/predict/route.ts +++ b/src/app/api/predict/route.ts @@ -14,8 +14,8 @@ const CandleSchema = z.object({ }); const PredictRequestSchema = z.object({ - pair: z.string().min(1), - timeframe: z.string().min(1), + pair: z.string().min(1).optional(), + timeframe: z.string().min(1).optional(), candles: z.array(CandleSchema), }); diff --git a/src/app/page.tsx b/src/app/page.tsx index cf74aa8..c3c9370 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -551,7 +551,14 @@ export default function Home() { }); if (!response.ok) { - throw new Error(`Prediction failed: ${response.statusText}`); + let message = response.statusText || 'Prediction failed'; + try { + const errorBody = await response.json(); + message = errorBody?.error || errorBody?.detail || message; + } catch { + // ignore parse errors + } + throw new Error(`Prediction failed: ${message}`); } const data = await response.json(); @@ -678,7 +685,14 @@ export default function Home() { }); if (!response.ok) { - throw new Error(`Batch prediction failed: ${response.statusText}`); + let message = response.statusText || 'Batch prediction failed'; + try { + const errorBody = await response.json(); + message = errorBody?.error || errorBody?.detail || message; + } catch { + // ignore parse errors + } + throw new Error(`Batch prediction failed: ${message}`); } const data = await response.json();