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.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 21:37:16 -04:00
1 parent 893a0ddec1
commit 6c6cc96060
1 file changed
+4 -1
+4 -1
View File
@@ -7,9 +7,12 @@ function safeGetAgent(db: AppDatabase, agentId: string | null | undefined) {
} }
try { try {
return db.getAgent(agentId); return db.getAgent(agentId);
} catch { } catch (error) {
if (error instanceof Error && error.message.startsWith("Agent not found:")) {
return null; return null;
} }
throw error;
}
} }
const MANAGEMENT_KEYWORDS = [ const MANAGEMENT_KEYWORDS = [