Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

debug(api-auth,onboarding): surface real errors instead of {} + loud-log silent api_auth_key rotation

Louis Beaumont72924759932e
diff --git a/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx b/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
index 32b9e6895..a70ce05fd 100644
--- a/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
+++ b/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
@@ -132,7 +132,13 @@ async function installAndEnable(slug: string, retries = 3): Promise<void> {
throw new Error(`enable ${slug} after install: ${enable2.status}`);
} catch (err) {
if (attempt === retries) throw err;
- console.warn(`pipe ${slug} attempt ${attempt}/${retries} failed, retrying...`, err);
+ // Stringify explicitly: `console.warn(..., err)` collapses Error
+ // instances to `{}` once they hit the Rust log capture (their
+ // useful fields aren't enumerable). This was the source of the
+ // unhelpful "pipe X attempt 1/3 failed, retrying... {}" log lines
+ // we couldn't diagnose for [email protected] on 2026-05-06.
+ const msg = (err as Error)?.stack ?? (err as Error)?.message ?? String(err);
+ console.warn(`pipe ${slug} attempt ${attempt}/${retries} failed, retrying...`, msg);
await new Promise((r) => setTimeout(r, 2000 * attempt));
}
}
@@ -202,7 +208,8 @@ export default function PickPipe() {
});
} catch {}
} catch (err) {
- console.error("failed to enable pipes:", err);
+ const msg = (err as Error)?.stack ?? (err as Error)?.message ?? String(err);
+ console.error("failed to enable pipes:", msg);
setError("Couldn't enable — try again or skip");
setPhase("choose");
setSelected(null);
@@ -221,7 +228,8 @@ export default function PickPipe() {
try {
// best-effort install of default pipe — don't block onboarding completion
await installAndEnable("todo-list-assistant").catch((e) => {
- console.warn("failed to install default pipe:", e);
+ const msg = (e as Error)?.stack ?? (e as Error)?.message ?? String(e);
+ console.warn("failed to install default pipe:", msg);
});
} catch {}
diff --git a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
index c3de2a6c6..d0ec8f462 100644
--- a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
@@ -764,7 +764,8 @@ export function RecordingSettings() {
false
);
} catch (error) {
- console.error("Failed to load devices:", error);
+ const msg = (error as Error)?.stack ?? (error as Error)?.message ?? String(error);
+ console.error("Failed to load devices:", msg);
}
};
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-sql-autocomplete.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-sql-autocomplete.tsx
index e361020f5..c510baba1 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-sql-autocomplete.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-sql-autocomplete.tsx
@@ -97,7 +97,8 @@ export function useSqlAutocomplete(type: "app" | "window" | "url") {
cache[type] = { data: result, timestamp: Date.now() };
}
} catch (error) {
- console.error("failed to fetch items:", error);
+ const msg = (error as Error)?.stack ?? (error as Error)?.message ?? String(error);
+ console.error("failed to fetch items:", msg);
} finally {
setIsLoading(false);
}
diff --git a/crates/screenpipe-engine/src/auth_key.rs b/crates/screenpipe-engine/src/auth_key.rs
index 935cbfc96..70c305fe8 100644
--- a/crates/screenpipe-engine/src/auth_key.rs
+++ b/crates/screenpipe-engine/src/auth_key.rs
@@ -26,13 +26,33 @@ pub async fn resolve_api_auth_key(data_dir: &Path, settings_key: Option<&str>) -
// Read the existing secret-store value once — used both as a fallback
// source and to avoid a no-op write when nothing has changed.
+ //
+ // CRITICAL: distinguish "no row" from "row exists but unreadable". If
+ // `get()` errors (decrypt failure, IO error), we MUST log loudly — the
+ // chain below will fall through to "auto-generate" and silently rotate
+ // the user's API key, breaking every consumer that cached the prior
+ // value (webview, MCP, CLI). Concrete trigger: built-from-source dev
+ // build wrote an encrypted `api_auth_key` whose keychain ACL is scoped
+ // to the dev bundle id; user later switches to the prod build, which
+ // can read the secrets table but the keychain ACL denies the decrypt
+ // for `screenpi.pe`. Result: rotation, mismatched in-memory caches,
+ // 401 storms — observed for [email protected] 2026-05-06.
let stored_key: Option<String> = if let Some(ref s) = store {
- s.get("api_auth_key")
- .await
- .ok()
- .flatten()
- .and_then(|bytes| String::from_utf8(bytes).ok())
- .filter(|k| !k.is_empty())
+ match s.get("api_auth_key").await {
+ Ok(Some(bytes)) => String::from_utf8(bytes).ok().filter(|k| !k.is_empty()),
+ Ok(None) => None,
+ Err(e) => {
+ tracing::error!(
+ "api auth: failed to read api_auth_key from secret store — \
+ resolver will fall through to auto-generate, rotating the \
+ key out from under cached consumers. Likely cause: keychain \
+ ACL mismatch (dev↔prod bundle id, recent encryption toggle, \
+ or revoked keychain item). Error: {}",
+ e
+ );
+ None
+ }
+ }
} else {
None
};