From d3379a1a678e5ef9915e021d9d5c595086a1cc83 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 10:19:10 -0600 Subject: [PATCH] fix(desktop-commander): treat cf 10007 as no baseline on first publish The second publish run reached the upload step and failed in the baseline probe: for a Worker that does not exist yet, `cf workers deployments list` answers APIError 10007 (404, "This Worker does not exist on your account") instead of an empty list. The baseline probe now maps exactly that shape to a null baseline; every other failure still propagates. Verified against run 45213914252's log. --- .../worker/upload-version.mjs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pkgs/desktop-commander/worker/upload-version.mjs b/pkgs/desktop-commander/worker/upload-version.mjs index abb3b86d6..ef96a58cd 100644 --- a/pkgs/desktop-commander/worker/upload-version.mjs +++ b/pkgs/desktop-commander/worker/upload-version.mjs @@ -85,10 +85,26 @@ function cfJson(argv) { return unwrapJson(output); } +// First publish: the Worker does not exist yet, and cf answers the +// deployments list with APIError 10007 (404) instead of an empty list. +// That specific shape means "no baseline"; every other failure is a +// real error and keeps propagating. +function listDeployments() { + try { + return cfJson(["workers", "deployments", "list", "--worker", config.worker, "--per-page", "1"]); + } catch (err) { + const text = `${err.stdout ?? ""}\n${err.stderr ?? ""}\n${err.message ?? ""}`; + if (text.includes("10007") || text.includes("does not exist on your account")) { + return null; + } + throw err; + } +} + let baselineDeployment = null; if (!dryRun) { - const deployments = cfJson(["workers", "deployments", "list", "--worker", config.worker, "--per-page", "1"]); - baselineDeployment = firstDeployment(deployments); + const deployments = listDeployments(); + baselineDeployment = deployments ? firstDeployment(deployments) : null; if (baselineDeployment) { if (typeof baselineDeployment?.versions?.[0]?.version_id !== "string" || !baselineDeployment.id) { throw new Error("cf could not identify the current active Worker deployment; refusing to upload");