From bb723c78452e0f694487bec522d64224feb7ae14 Mon Sep 17 00:00:00 2001 From: scotttong Date: Sat, 22 Aug 2026 05:00:18 -0700 Subject: [PATCH] Guard auth_token_missing run-event persistence so it can't abort adapter launch The missing-token warning is purely diagnostic; if appendRunEvent fails (database or publication error) the run should still launch, losing only the warning. Addresses Greptile review. Co-Authored-By: Claude Fable 5 --- server/src/services/heartbeat.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts index 9ae529b9b24..79595e7df18 100644 --- a/server/src/services/heartbeat.ts +++ b/server/src/services/heartbeat.ts @@ -15954,14 +15954,23 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {}) }, "local agent jwt secret missing or invalid; running without injected PAPERCLIP_API_KEY", ); - await appendRunEvent(currentRun, seq++, { - eventType: "adapter.auth_token_missing", - stream: "system", - level: "warn", - message: - "Agent JWT secret is missing; this run has no PAPERCLIP_API_KEY, so unauthenticated API writes would be attributed to the board instead of the agent.", - payload: { adapterType: agent.adapterType }, - }); + try { + await appendRunEvent(currentRun, seq++, { + eventType: "adapter.auth_token_missing", + stream: "system", + level: "warn", + message: + "Agent JWT secret is missing; this run has no PAPERCLIP_API_KEY, so unauthenticated API writes would be attributed to the board instead of the agent.", + payload: { adapterType: agent.adapterType }, + }); + } catch (err) { + // The event is purely diagnostic; a persistence failure must not + // prevent the adapter from launching. + logger.warn( + { runId: run.id, err }, + "failed to persist adapter.auth_token_missing run event", + ); + } } let adapterFinalizeOutcome: "succeeded" | "failed" | null = null; const inspectFinalizeWorkspaceBranch = async () => {