From db9b0ba5aae0e75da1cee99107d15413e40a76a3 Mon Sep 17 00:00:00 2001 From: "Doink (OpenClaw)" Date: Wed, 25 Feb 2026 15:06:17 -0800 Subject: [PATCH] fix: omit undefined fields in lock error messages Lock error messages interpolated `lock.reason` directly, showing "locked by ms: undefined" when no reason was provided. Now gracefully omits the reason clause when absent and falls back to "unknown" for missing lockedBy. Fixes #58 Co-Authored-By: Charlie Hulcher --- src/daemon/lock-manager.ts | 2 +- src/daemon/server.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/daemon/lock-manager.ts b/src/daemon/lock-manager.ts index 0bc1d8f..8866ed1 100644 --- a/src/daemon/lock-manager.ts +++ b/src/daemon/lock-manager.ts @@ -55,7 +55,7 @@ export class LockManager { const existing = this.check(resolved); if (existing?.type === "manual") { throw new Error( - `Already manually locked by ${existing.lockedBy}: ${existing.reason}`, + `Already manually locked by ${existing.lockedBy ?? "unknown"}${existing.reason ? `: ${existing.reason}` : ""}`, ); } const lock: Lock = { diff --git a/src/daemon/server.ts b/src/daemon/server.ts index 04abf3c..3e33341 100644 --- a/src/daemon/server.ts +++ b/src/daemon/server.ts @@ -497,7 +497,7 @@ function createRequestHandler(ctx: HandlerContext) { if (lock && !params.force) { if (lock.type === "manual") { throw new Error( - `Directory locked by ${lock.lockedBy}: ${lock.reason}. Use --force to override.`, + `Directory locked by ${lock.lockedBy ?? "unknown"}${lock.reason ? `: ${lock.reason}` : ""}. Use --force to override.`, ); } throw new Error(