{"record":{"id":"fd16904d5c63c600","repo":"can1357/oh-my-pi","slug":"formatverificationfailure-verification-options","errorCode":null,"errorMessage":"${formatVerificationFailure(verification, options.expectedVersion)}; restored previous ${APP_NAME} binary","messagePattern":"(.+?); restored previous (.+?) binary","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/update-cli.ts","lineNumber":1295,"sourceCode":"\t\t// `backupPath` is unique per attempt (see updateViaBinaryAt), so this rename\n\t\t// never has to overwrite — or unlink — a possibly-locked leftover from an\n\t\t// earlier run. Renaming the running executable itself is permitted on\n\t\t// Windows; only deleting its still-mapped image is not.\n\t\t// A missing target is tolerated: repairing a launcher that a failed\n\t\t// package-manager reinstall removed installs the binary at a vacant\n\t\t// path. There is then nothing to restore, so a verification failure\n\t\t// leaves the new binary in place rather than the previous nothing.\n\t\ttry {\n\t\t\tawait fs.promises.rename(options.targetPath, options.backupPath);\n\t\t\tbackupReady = true;\n\t\t} catch (err) {\n\t\t\tif (!isEnoent(err)) throw err;\n\t\t}\n\t\tawait fs.promises.rename(options.tempPath, options.targetPath);\n\n\t\tconst verification = await options.verifyInstalledVersion(options.expectedVersion);\n\t\tif (!verification.ok) {\n\t\t\tthrow new Error(\n\t\t\t\t`${formatVerificationFailure(verification, options.expectedVersion)}; restored previous ${APP_NAME} binary`,\n\t\t\t);\n\t\t}\n\n\t\tbackupReady = false;\n\t\t// Swap done and verified. On Windows the backup is still the running\n\t\t// process image and cannot be unlinked until this process exits, so a\n\t\t// failure here must NOT fail an otherwise-successful update.\n\t\tawait removeBackupBestEffort(options.backupPath);\n\t\treturn verification;\n\t} catch (err) {\n\t\tif (backupReady) {\n\t\t\tawait unlinkIfExists(options.targetPath);\n\t\t\tawait fs.promises.rename(options.backupPath, options.targetPath);\n\t\t}\n\t\tawait unlinkIfExists(options.tempPath);\n\t\tthrow err;\n\t}","sourceCodeStart":1277,"sourceCodeEnd":1313,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/update-cli.ts#L1277-L1313","documentation":"Thrown during the binary swap step of `omp update` when, after renaming the new binary into place, the post-install verification (`verifyInstalledVersion`) reports the installed version does not match the expected version. The previous binary was restored from backup, and the message combines the verification-failure detail with that recovery note.","triggerScenarios":"`options.verifyInstalledVersion(options.expectedVersion)` returns {ok:false} right after `fs.promises.rename(tempPath, targetPath)` — e.g. the new binary immediately crashes, reports a different version, AV quarantined the file, or the rename landed a corrupt download.","commonSituations":"Antivirus/EDR blocking or quarantining the freshly written executable, partial/corrupted download that still ran, filesystem sync issues on network drives, or a build uploaded with a mismatched version string.","solutions":["Retry `omp update` — the previous binary was restored, so nothing is broken","Check AV/EDR quarantine logs and allowlist the omp binary path","Verify the released asset's version matches expectations (regression on the release side) and report it","Update manually: download the binary from GitHub releases and replace the install yourself"],"exampleFix":"// before: AV keeps quarantining the new binary\nomp update  // verification failed; restored previous binary\n// after: allowlist the install dir, then retry\n# e.g. Windows Defender exclusion for the omp install path\nomp update","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runUpdate();\n} catch (err) {\n  if (String(err?.message).includes(\"restored previous\")) {\n    // the old binary is intact; safe to retry or report\n    console.error(`Update rolled back: ${err.message}`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Allowlist the omp install directory in AV/EDR software","Keep enough free disk space for temp+target binaries during update","Avoid running updates from network/queued filesystems with slow sync","Retry the update once after a rollback; persistent failure usually means release-side corruption"],"tags":["update-verification","binary-install","updater"],"backgroundTag":"post-install-version-verification-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}