From 71cea76d60e420c136a1ee7b4cc5e9e53ecfd920 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 10:33:54 -0600 Subject: [PATCH] fix(desktop-commander): resolve uploaded version by tag; drop deployments --message Publish run 45216887574 actually uploaded its version (tag dc-b25edb16077d-run-45216887574-attempt-1) and then failed parsing cf's versions-create stdout, which is a human panel in this cf build, not JSON. upload-version.mjs now resolves the uploaded version by its unique tag through the versions list (which does emit JSON) and refuses unless exactly one version carries it. promote.mjs passed --message to `cf workers deployments create`, which this cf build rejects as an unknown argument; the flag is dropped (the deployment keeps its provenance through the manifest and the run records). The orphaned version from run 45216887574 was promoted by a recorded operator action on #13404 (its upload was genuine: main sha, correct secrets, failure confined to post-upload parsing), restoring latest == active so the inheritance guard passes for the next publish. --- pkgs/desktop-commander/worker/promote.mjs | 1 - pkgs/desktop-commander/worker/upload-version.mjs | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/desktop-commander/worker/promote.mjs b/pkgs/desktop-commander/worker/promote.mjs index d2440431a..9d4a6b168 100644 --- a/pkgs/desktop-commander/worker/promote.mjs +++ b/pkgs/desktop-commander/worker/promote.mjs @@ -81,7 +81,6 @@ const created = cfJson([ "--worker", config.worker, "--strategy", "percentage", "--versions", JSON.stringify([{ version_id: manifest.versionId, percentage: 100 }]), - "--message", `promote ${manifest.tag} (${manifest.sha})`, ]); const deploymentId = created?.id ?? created?.deployment_id; console.log(`promoted ${config.worker} version ${manifest.versionId} (tag ${manifest.tag}) to 100%${deploymentId ? `; deployment ${deploymentId}` : ""}`); diff --git a/pkgs/desktop-commander/worker/upload-version.mjs b/pkgs/desktop-commander/worker/upload-version.mjs index ef96a58cd..c6dcf7ead 100644 --- a/pkgs/desktop-commander/worker/upload-version.mjs +++ b/pkgs/desktop-commander/worker/upload-version.mjs @@ -126,14 +126,20 @@ if (dryRun) { process.stdout.write(output); console.log(`dry run: ${config.worker} version is valid; nothing uploaded`); } else { - const version = unwrapJson(output); + // cf's versions-create stdout is a human panel in this build, not + // JSON — resolve the uploaded version by its unique tag instead of + // parsing that output. Exactly one version may carry the tag. + const listed = cfJson(["workers", "versions", "list", "--worker-id", config.worker, "--per-page", "50"]); + const allVersions = Array.isArray(listed) ? listed : listed?.versions ?? listed?.items ?? []; + const matches = allVersions.filter((v) => v.annotations?.["workers/tag"] === tag); + if (matches.length !== 1) { + throw new Error(`expected exactly one uploaded version with tag ${tag}, found ${matches.length}; refusing to emit provenance`); + } + const version = matches[0]; const versionId = version.id ?? version.version_id; if (typeof versionId !== "string" || !versionId) { throw new Error("cf did not return the uploaded version ID; refusing to emit provenance"); } - if (version.annotations?.["workers/tag"] && version.annotations["workers/tag"] !== tag) { - throw new Error("cf returned an uploaded version with an unexpected tag"); - } if (baselineDeployment) { const deployment = firstDeployment(cfJson(["workers", "deployments", "list", "--worker", config.worker, "--per-page", "1"])); if (deployment?.id !== baselineDeployment.id || deployment?.versions?.[0]?.version_id !== baselineDeployment.versions[0].version_id) {