{"record":{"id":"6c7ca1381c2ef499","repo":"can1357/oh-my-pi","slug":"downloaded-binary-size-mismatch-expected-option","errorCode":null,"errorMessage":"Downloaded binary size mismatch: expected ${options.expectedSize} bytes, received ${size}","messagePattern":"Downloaded binary size mismatch: expected (.+?) bytes, received (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/update-cli.ts","lineNumber":337,"sourceCode":"\t\t\tsize += chunk.byteLength;\n\t\t\tif (size > options.expectedSize) {\n\t\t\t\tcallback(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`Downloaded binary size mismatch: expected ${options.expectedSize} bytes, received at least ${size}`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thash.update(chunk);\n\t\t\tcallback(null, chunk);\n\t\t},\n\t});\n\n\ttry {\n\t\tawait pipeline(response.body, verifier, fs.createWriteStream(options.targetPath, { mode: 0o600 }));\n\t\tconst digest = `sha256:${hash.digest(\"hex\")}`;\n\t\tif (size !== options.expectedSize) {\n\t\t\tthrow new Error(`Downloaded binary size mismatch: expected ${options.expectedSize} bytes, received ${size}`);\n\t\t}\n\t\tif (digest !== options.expectedDigest) {\n\t\t\tthrow new Error(`Downloaded binary digest mismatch: expected ${options.expectedDigest}, received ${digest}`);\n\t\t}\n\t\tawait fs.promises.chmod(options.targetPath, 0o755);\n\t} catch (err) {\n\t\tawait unlinkIfExists(options.targetPath);\n\t\tif (isTimeoutError(err)) {\n\t\t\tthrow new Error(\"Timed out downloading release binary after 15 minutes\", { cause: err });\n\t\t}\n\t\tif (isUnsupportedProxyError(err)) throw new Error(unsupportedProxyMessage(), { cause: err });\n\t\tthrow err;\n\t}\n}\n\n/** Result from running the installed binary and parsing its reported version. */\nexport interface InstalledVersionVerification {\n\tok: boolean;","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/update-cli.ts#L319-L355","documentation":"Thrown by downloadVerifiedBinary after the download pipeline completes when the number of bytes streamed to the target file does not equal options.expectedSize from the release manifest. This is an integrity check guarding against truncated or padded downloads before the binary is trusted and chmod'ed executable. The partially-written file is deleted by the surrounding catch before this point via unlinkIfExists in the outer handler.","triggerScenarios":"The response body ended early (connection closed mid-stream) but the pipeline resolved without an error; a middlebox/proxy truncated the transfer; disk-full silently truncated the write stream; expectedSize from the release manifest disagrees with the actual asset (release re-uploaded with a stale manifest).","commonSituations":"Unstable Wi-Fi or mobile hotspot dropping the connection near the end of a large binary download; corporate proxies with transfer size limits; a release pipeline that re-published an asset without updating the manifest.","solutions":["Re-run `omp update` — a complete retry re-downloads and re-verifies from scratch.","Check free disk space on the target filesystem (`df -h`) and retry.","Bypass proxies/VPNs that may truncate long transfers and retry.","If it reproduces on a good connection, report the release manifest/asset size mismatch to the project maintainers."],"exampleFix":"// before: disk full causes truncated download\n$ omp update\n// Error: Downloaded binary size mismatch: expected 48231424 bytes, received 12058368\n// after: free space, then retry\n$ df -h ~/.omp && omp update","handlingStrategy":"retry","validationCode":"const stat = await fs.statfs(path.dirname(targetPath)).catch(() => null);\nif (stat && stat.bavail * stat.bsize < expectedSize) throw new Error(\"Insufficient disk space for update download\");","typeGuard":"function isSizeMismatch(err: unknown): boolean {\n  return err instanceof Error && err.message.includes(\"Downloaded binary size mismatch\");\n}","tryCatchPattern":"try {\n  await runUpdate();\n} catch (err) {\n  if (isSizeMismatch(err)) {\n    // truncated transfer: free disk space / bypass proxy, then retry once\n    return runUpdate();\n  }\n  throw err;\n}","preventionTips":["Ensure ample free disk space before updating","Avoid proxies with transfer-size limits","If it recurs on clean connections, compare asset size vs release notes and report"],"tags":["download","integrity","network","update-cli"],"backgroundTag":"checksum-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}