Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: fail closed on a malformed workspace-policy response

Gabriel Stein92b21b130b81
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index fbc8cbb46..a2a553c91 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -7682,8 +7682,14 @@ class IPCHandlers {
if (!response.ok) throw new Error(`API error: ${response.status}`);
const json = await response.json();
- const data = json?.data ?? null;
- if (data && data.managed) {
+ const data = json?.data;
+ // Treat a malformed 200 body as a failure, not an authoritative
+ // "unmanaged" verdict, so the catch serves the cached policy (fail-closed)
+ // instead of deleting it and unlocking the user.
+ if (!data || typeof data.managed !== "boolean") {
+ throw new Error("Malformed policy response");
+ }
+ if (data.managed) {
try {
fs.writeFileSync(cachePath, JSON.stringify(data), { mode: 0o600 });
} catch (err) {