From 88f12b08223fa1c0ff5275c8cc2f96ed64e887ab Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Sun, 2 Nov 2025 23:38:56 -0600 Subject: [PATCH] core: prevent TypeError when error handling encounters non-object errors When API errors like token limit exceeded errors are passed as strings to error checking methods, the 'in' operator would throw a TypeError. This fix adds a type guard to check that the input is an object before attempting to access its properties, allowing proper error classification even when encountering unexpected error formats from providers. --- packages/opencode/src/util/error.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/util/error.ts b/packages/opencode/src/util/error.ts index d488abb6..12c27a0a 100644 --- a/packages/opencode/src/util/error.ts +++ b/packages/opencode/src/util/error.ts @@ -27,7 +27,7 @@ export abstract class NamedError extends Error { } static isInstance(input: any): input is InstanceType { - return "name" in input && input.name === name + return typeof input === "object" && "name" in input && input.name === name } schema() {