From 8779f184bbc64fa1fe8c30f0582ef4235844334c Mon Sep 17 00:00:00 2001 From: "t3-code[bot]" <269035359+t3-code[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 21:06:57 +0000 Subject: [PATCH] fix(web): surface malformed theme details --- apps/web/src/openVsxThemes.test.ts | 19 +++++++++++++++++++ apps/web/src/openVsxThemes.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/web/src/openVsxThemes.test.ts b/apps/web/src/openVsxThemes.test.ts index 531f43e32f..1d7e9ef4b3 100644 --- a/apps/web/src/openVsxThemes.test.ts +++ b/apps/web/src/openVsxThemes.test.ts @@ -99,6 +99,25 @@ describe("Open VSX themes", () => { ); }); + it("reports an unavailable search when every detail response is malformed", async () => { + vi.stubGlobal( + "fetch", + vi.fn(async (input: RequestInfo | URL) => { + if (String(input).includes("/-/search?")) { + return new Response( + JSON.stringify({ extensions: [{ namespace: "demo", name: "theme" }] }), + { status: 200 }, + ); + } + return new Response("not json", { status: 200 }); + }), + ); + + await expect(searchOpenVsxThemes("dracula")).rejects.toThrow( + "Open VSX theme details are unavailable", + ); + }); + it("downloads a verified VSIX, reads JSONC includes, and pairs contributed variants", async () => { const zip = new JSZip(); zip.file( diff --git a/apps/web/src/openVsxThemes.ts b/apps/web/src/openVsxThemes.ts index 302fefc5f5..e9506d3365 100644 --- a/apps/web/src/openVsxThemes.ts +++ b/apps/web/src/openVsxThemes.ts @@ -148,7 +148,7 @@ export async function searchOpenVsxThemes( try { return extensionFromDetail(JSON.parse(new TextDecoder().decode(detailBytes))); } catch { - return null; + throw new Error("Open VSX returned unreadable theme details."); } }), );