Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix(dashboard): guard res.ok on the knowledge-graph fetch

Daniel Zivkovic63a66ae5bb0c
diff --git a/understand-anything-plugin/packages/dashboard/src/App.tsx b/understand-anything-plugin/packages/dashboard/src/App.tsx
index cd1b33c7..cbeb0274 100644
--- a/understand-anything-plugin/packages/dashboard/src/App.tsx
+++ b/understand-anything-plugin/packages/dashboard/src/App.tsx
@@ -133,7 +133,26 @@ function Dashboard({ accessToken }: { accessToken: string }) {
useEffect(() => {
fetch(dataUrl("knowledge-graph.json", accessToken))
- .then((res) => res.json())
+ .then(async (res) => {
+ // Guard res.ok before parsing (matching the meta.json/config.json/
+ // diff-overlay.json/domain-graph.json fetches in this file). Without
+ // this, a serving/config failure returns a 404 JSON error body that
+ // gets parsed and handed to validateGraph, which fails project-metadata
+ // validation and surfaces the misleading "Invalid knowledge graph:
+ // Missing or invalid project metadata" instead of the real cause
+ // (graph file not found / GRAPH_DIR unset). See issues #288, #406.
+ if (!res.ok) {
+ let detail = `HTTP ${res.status}`;
+ try {
+ const body = await res.json();
+ if (body?.error) detail = body.error;
+ } catch {
+ /* non-JSON error body; keep the status code */
+ }
+ throw new Error(detail);
+ }
+ return res.json();
+ })
.then((data: unknown) => {
const result = validateGraph(data);
if (result.success && result.data) {