From 848d8de3fe458dc0b1bec5bde7a1173feda01699 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 13 Aug 2025 09:57:55 -0800 Subject: [PATCH 1/2] Use truncated version with signature fallback --- src/storage.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/storage.ts b/src/storage.ts index bbdb508c..d550ff60 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -8,6 +8,7 @@ import fs from "fs/promises"; import { IncomingMessage } from "http"; import path from "path"; import prettyBytes from "pretty-bytes"; +import * as semver from "semver"; import * as vscode from "vscode"; import { errToStr } from "./api-helper"; import * as cli from "./cliManager"; @@ -139,6 +140,10 @@ export class Storage { // and to log for debugging. const buildInfo = await restClient.getBuildInfo(); this.output.info("Got server version", buildInfo.version); + const parsedVersion = semver.parse(buildInfo.version); + if (!parsedVersion) { + throw new Error(`Got invalid version from deployment: ${buildInfo.version}`) + } // Check if there is an existing binary and whether it looks valid. If it // is valid and matches the server, or if it does not match the server but @@ -230,9 +235,11 @@ export class Storage { // named exactly the same with an appended `.asc` (such as // coder-windows-amd64.exe.asc or coder-linux-amd64.asc). binSource + ".asc", - // The releases.coder.com bucket does not include the leading "v". - // The signature name follows the same rule as above. - `https://releases.coder.com/coder-cli/${buildInfo.version.replace(/^v/, "")}/${binName}.asc`, + // The releases.coder.com bucket does not include the leading "v", + // and unlike what we get from buildinfo it uses a truncated version + // with only major.minor.patch. The signature name follows the same + // rule as above. + `https://releases.coder.com/coder-cli/${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}/${binName}.asc`, ]); } From c4142386caa04c5d34ed0d6278bfea463e16fa4d Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 13 Aug 2025 10:06:16 -0800 Subject: [PATCH 2/2] fmt --- src/storage.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/storage.ts b/src/storage.ts index d550ff60..614b52aa 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -142,7 +142,9 @@ export class Storage { this.output.info("Got server version", buildInfo.version); const parsedVersion = semver.parse(buildInfo.version); if (!parsedVersion) { - throw new Error(`Got invalid version from deployment: ${buildInfo.version}`) + throw new Error( + `Got invalid version from deployment: ${buildInfo.version}`, + ); } // Check if there is an existing binary and whether it looks valid. If it