From 751f99a82fb23924afb20fe1bb369517a0d4fd9e Mon Sep 17 00:00:00 2001 From: Anton Evseev <78427278+slayoffer@users.noreply.github.com> Date: Fri, 30 Jan 2026 18:00:56 +1000 Subject: [PATCH] fix(control-plane): handle undefined response.data in graph route (#239) When the backend graph API returns an error, the SDK sets response.data to undefined. NextResponse.json(undefined) throws "Value is not JSON serializable". Check for error/missing data before serializing. --- hindsight-control-plane/src/app/api/graph/route.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hindsight-control-plane/src/app/api/graph/route.ts b/hindsight-control-plane/src/app/api/graph/route.ts index 077278d4..f93fb605 100644 --- a/hindsight-control-plane/src/app/api/graph/route.ts +++ b/hindsight-control-plane/src/app/api/graph/route.ts @@ -24,6 +24,14 @@ export async function GET(request: NextRequest) { }, }); + if (response.error || !response.data) { + console.error("Graph API error:", response.error); + return NextResponse.json( + { error: response.error || "Failed to fetch graph data" }, + { status: 500 }, + ); + } + return NextResponse.json(response.data, { status: 200 }); } catch (error) { console.error("Error fetching graph data:", error);