From 1152b25866532bf2171c823add06a1e5edde46f9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 13:20:53 +0100 Subject: [PATCH] fix(gateway): guard trim crashes in subagent flow --- CHANGELOG.md | 1 + src/agents/subagent-announce.ts | 2 +- src/gateway/server-methods/agent.ts | 4 ++-- src/gateway/session-utils.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb611d63dcf..9f55378e52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Docs: https://docs.openclaw.ai ### Fixes +- Gateway/Subagents: guard gateway and subagent session-key/message trim paths against undefined inputs to prevent early `Cannot read properties of undefined (reading 'trim')` crashes during subagent spawn and wait flows. - Agents/Workspace: guard `resolveUserPath` against undefined/null input to prevent `Cannot read properties of undefined (reading 'trim')` crashes when workspace paths are missing in embedded runner flows. - Auth/Profiles: keep active `cooldownUntil`/`disabledUntil` windows immutable across retries so mid-window failures cannot extend recovery indefinitely; only recompute a backoff window after the previous deadline has expired. This resolves cron/inbound retry loops that could trap gateways until manual `usageStats` cleanup. (#23516, #23536) Thanks @arosstale. - Channels/Security: fail closed on missing provider group policy config by defaulting runtime group policy to `allowlist` (instead of inheriting `channels.defaults.groupPolicy`) when `channels.` is absent across message channels, and align runtime + security warnings/docs to the same fallback behavior (Slack, Discord, iMessage, Telegram, WhatsApp, Signal, LINE, Matrix, Mattermost, Google Chat, IRC, Nextcloud Talk, Feishu, and Zalo user flows; plus Discord message/native-command paths). (#23367) Thanks @bmendonca3. diff --git a/src/agents/subagent-announce.ts b/src/agents/subagent-announce.ts index 36573250e4d..81804eea634 100644 --- a/src/agents/subagent-announce.ts +++ b/src/agents/subagent-announce.ts @@ -502,7 +502,7 @@ function resolveRequesterStoreKey( cfg: ReturnType, requesterSessionKey: string, ): string { - const raw = requesterSessionKey.trim(); + const raw = (requesterSessionKey ?? "").trim(); if (!raw) { return raw; } diff --git a/src/gateway/server-methods/agent.ts b/src/gateway/server-methods/agent.ts index 896a1ff0c7f..1f1e0df19ad 100644 --- a/src/gateway/server-methods/agent.ts +++ b/src/gateway/server-methods/agent.ts @@ -217,7 +217,7 @@ export const agentHandlers: GatewayRequestHandlers = { } const normalizedAttachments = normalizeRpcAttachmentsToChatAttachments(request.attachments); - let message = request.message.trim(); + let message = (request.message ?? "").trim(); let images: Array<{ type: "image"; data: string; mimeType: string }> = []; if (normalizedAttachments.length > 0) { try { @@ -695,7 +695,7 @@ export const agentHandlers: GatewayRequestHandlers = { return; } const p = params; - const runId = p.runId.trim(); + const runId = (p.runId ?? "").trim(); const timeoutMs = typeof p.timeoutMs === "number" && Number.isFinite(p.timeoutMs) ? Math.max(0, Math.floor(p.timeoutMs)) diff --git a/src/gateway/session-utils.ts b/src/gateway/session-utils.ts index 5da23cee600..fc4decaa688 100644 --- a/src/gateway/session-utils.ts +++ b/src/gateway/session-utils.ts @@ -430,7 +430,7 @@ export function resolveSessionStoreKey(params: { cfg: OpenClawConfig; sessionKey: string; }): string { - const raw = params.sessionKey.trim(); + const raw = (params.sessionKey ?? "").trim(); if (!raw) { return raw; }