Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([tolerant-fetch-json-additional-clients]): surface insights non-JSON body as error, not empty success

[._.]/ Adam Eivy015e617becdf
diff --git a/server/services/insightsService.js b/server/services/insightsService.js
index a55daf6206..4b0252a076 100644
--- a/server/services/insightsService.js
+++ b/server/services/insightsService.js
@@ -195,7 +195,16 @@ async function callProviderAISimple(provider, model, prompt, { temperature = 0.3
return { error: `Provider returned ${response.status}: ${errorText}` };
}
- const data = await readResponseJson(response);
+ // Sentinel fallback: a non-JSON/blank 200 body must surface as an error, not
+ // an empty `{ text: '' }` success — both callers persist the result
+ // (refreshCrossDomainNarrative → narrative.json, generateInsightThemes →
+ // themes.json), so a masqueraded-empty success would overwrite the cached
+ // narrative/themes with nothing. A valid body (even one with empty content)
+ // still flows through unchanged.
+ const data = await readResponseJson(response, { fallback: null, emptyValue: null });
+ if (!data) {
+ return { error: `Provider returned a non-JSON response (${response.status})` };
+ }
return { text: data.choices?.[0]?.message?.content || '' };
}