Skip to content

Commit 751f99a

Browse files
authored
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.
1 parent 49ae55a commit 751f99a

File tree

1 file changed

+8
-0
lines changed
  • hindsight-control-plane/src/app/api/graph

1 file changed

+8
-0
lines changed

hindsight-control-plane/src/app/api/graph/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export async function GET(request: NextRequest) {
2424
},
2525
});
2626

27+
if (response.error || !response.data) {
28+
console.error("Graph API error:", response.error);
29+
return NextResponse.json(
30+
{ error: response.error || "Failed to fetch graph data" },
31+
{ status: 500 },
32+
);
33+
}
34+
2735
return NextResponse.json(response.data, { status: 200 });
2836
} catch (error) {
2937
console.error("Error fetching graph data:", error);

0 commit comments

Comments
 (0)