From d6eff3b3a31192b3c37e03ebff278cbc8ace2023 Mon Sep 17 00:00:00 2001 From: CodinCat Date: Tue, 15 Jul 2025 09:13:12 +0900 Subject: improve error handling and logging for GitHub API failures in upgrade and install script (#972) --- packages/opencode/src/installation/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts index 9dfe22432..ab631a8d2 100644 --- a/packages/opencode/src/installation/index.ts +++ b/packages/opencode/src/installation/index.ts @@ -140,6 +140,12 @@ export namespace Installation { export async function latest() { return fetch("https://api.github.com/repos/sst/opencode/releases/latest") .then((res) => res.json()) - .then((data) => data.tag_name.slice(1) as string) + .then((data) => { + if (typeof data.tag_name !== "string") { + log.error("GitHub API error", data) + throw new Error("failed to fetch latest version") + } + return data.tag_name.slice(1) as string + }) } } -- cgit v1.2.3