{"record":{"id":"8d06b533c19ae78f","repo":"Hmbown/CodeWhale","slug":"the-downloaded-app-has-a-different-version","errorCode":null,"errorMessage":"The downloaded app has a different version.","messagePattern":"The downloaded app has a different version\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/app/updates.mjs","lineNumber":107,"sourceCode":"  for(let redirects=0;redirects<4;redirects++) {\n    response=await fetch(url,{redirect:\"manual\",signal:AbortSignal.timeout(60_000)});\n    if(![301,302,303,307,308].includes(response.status)) break;\n    const next=new URL(response.headers.get(\"location\"),url);\n    if(next.protocol!==\"https:\"||![\"github.com\",\"release-assets.githubusercontent.com\",\"objects.githubusercontent.com\"].includes(next.hostname)) throw new Error(\"The update download redirected to an unexpected host.\");\n    url=next.href;\n  }\n  if(!response?.ok) throw new Error(\"The update could not be downloaded. Your current app is unchanged.\");\n  const bytes=await responseBytes(response,update.size);\n  if(bytes.length!==update.size||crypto.createHash(\"sha256\").update(bytes).digest(\"hex\")!==update.sha256) throw new Error(\"The update checksum did not match. Your current app is unchanged.\");\n  validateReleaseZip(bytes);\n  const stage=fs.mkdtempSync(path.join(os.tmpdir(),\"codewhale-cu-release-\"));\n  try {\n    const archive=path.join(stage,\"release.zip\"); fs.writeFileSync(archive,bytes,{mode:0o600});\n    const result=spawnSync(\"ditto\",[\"-x\",\"-k\",archive,stage],{encoding:\"utf8\"});\n    if(result.status!==0) throw new Error(\"The update could not be unpacked.\");\n    const bundle=path.join(stage,`${APP_NAME}.app`); verifyReleaseBundle(bundle);\n    const version=spawnSync(\"/usr/libexec/PlistBuddy\",[\"-c\",\"Print :CFBundleShortVersionString\",path.join(bundle,\"Contents\",\"Info.plist\")],{encoding:\"utf8\"});\n    if(version.status!==0||version.stdout.trim()!==update.version) throw new Error(\"The downloaded app has a different version.\");\n    return {stage,bundle};\n  } catch(error) { fs.rmSync(stage,{recursive:true,force:true}); throw error; }\n}\n\nexport async function restartWithUpdate(prepared,destination) {\n  const logDir=path.join(os.homedir(),\"Library\",\"Logs\",APP_NAME); fs.mkdirSync(logDir,{recursive:true});\n  const log=fs.openSync(path.join(logDir,\"update.log\"),\"a\",0o600);\n  const child=spawn(process.execPath,[fileURLToPath(import.meta.url),\"--apply\",prepared.bundle,destination,String(process.pid),String(process.ppid)],{detached:true,stdio:[\"ignore\",log,log]});\n  try { await new Promise((resolve,reject)=>{child.once(\"spawn\",resolve);child.once(\"error\",reject);}); child.unref(); }\n  finally { fs.closeSync(log); }\n}\n\nif(process.argv[1]===fileURLToPath(import.meta.url)&&process.argv[2]===\"--apply\") {\n  const [source,destination,owner,launcher]=process.argv.slice(3);\n  let result;\n  try {\n    verifyReleaseBundle(source);\n    process.kill(Number(owner),\"SIGTERM\");","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/app/updates.mjs#L89-L125","documentation":"After extraction, prepareUpdate() reads CFBundleShortVersionString from the staged app bundle's Info.plist via /usr/libexec/PlistBuddy and requires it to equal update.version. A mismatch (or PlistBuddy failing) means the bundle inside the verified archive does not carry the version the release metadata promised, so the update is aborted and the staging directory removed.","triggerScenarios":"The release zip contains a bundle built from a different commit than the tagged version (mis-cut release); update.version was bumped in metadata without rebuilding the app; PlistBuddy exits non-zero because Info.plist is missing or malformed inside the bundle; the zip's top-level app name differs from APP_NAME so verifyReleaseBundle/pickup picked an unexpected bundle.","commonSituations":"A release pipeline that re-tagged a version without re-archiving; CI caching a stale .app artifact into the release zip; hand-repacked update zips for testing; a partially uploaded asset from an interrupted release run.","solutions":["Re-run the update check and retry — if the release was repaired and re-uploaded, the new archive will match its declared version.","Verify on the release page that the asset's bundle Info.plist CFBundleShortVersionString equals the tag version; if not, the release itself is mis-cut and must be re-published.","If testing with a locally built zip, rebuild it so the bundle's CFBundleShortVersionString matches the version you pass in the descriptor.","Confirm the zip contains `<APP_NAME>.app` at its root with a valid Contents/Info.plist."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await prepareUpdate(update); } catch (e) { if (/different version/.test(e.message)) { /* re-check for updates; if it persists, the published release is mis-cut — report it */ } else throw e; }","preventionTips":["Never hand-repack release zips for production update flows.","Verify release CI stamps CFBundleShortVersionString with the tag version before publishing.","Re-run check-for-update after any release repair/re-upload."],"tags":["version","release","integrity","macos"],"backgroundTag":"version-mismatch","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}