From f5abbfabbf5e7454e0ab622a76c26148e3bcf23d Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 27 Apr 2026 16:46:19 -0400 Subject: [PATCH] core: fix crash when message attachments array is undefined Prevents runtime errors by ensuring undefined attachments are converted to an empty array before spreading into the message parts. This fixes scenarios where tool responses without attachments would cause the session processor to fail. --- packages/opencode/src/session/processor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/session/processor.ts b/packages/opencode/src/session/processor.ts index 890af22e7d..f8ce1243fd 100644 --- a/packages/opencode/src/session/processor.ts +++ b/packages/opencode/src/session/processor.ts @@ -386,12 +386,12 @@ export const layer: Layer.Layer< type: "text", text: value.output.output, }, - ...value.output.attachments?.map((item: MessageV2.FilePart) => ({ + ...(value.output.attachments?.map((item: MessageV2.FilePart) => ({ type: "file", uri: item.url, mime: item.mime, name: item.filename, - })), + })) ?? []), ], provider: { executed: toolCall?.part.metadata?.providerExecuted === true,