From 6c6cc96060aeca63f59c04fb1e5ba613f964451d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 21:37:16 -0400 Subject: [PATCH] fix(agent-permissions): propagate DB errors instead of silently denying safeGetAgent was catching all errors and returning null, causing every permission check (canControlAgent / canManageOrganization / canRequestHire) to silently deny when the database threw. Only swallow the 'Agent not found' case and let real DB errors propagate up to registerHandle's sanitizer. --- src/main/agent-permissions.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/agent-permissions.ts b/src/main/agent-permissions.ts index 65e9bb59..d14b6906 100644 --- a/src/main/agent-permissions.ts +++ b/src/main/agent-permissions.ts @@ -7,8 +7,11 @@ function safeGetAgent(db: AppDatabase, agentId: string | null | undefined) { } try { return db.getAgent(agentId); - } catch { - return null; + } catch (error) { + if (error instanceof Error && error.message.startsWith("Agent not found:")) { + return null; + } + throw error; } }