{"record":{"id":"e0974b2c6619f649","repo":"JuliusBrussee/caveman","slug":"signature-check-failed-for-artifact-partial-download-deleted","errorCode":null,"errorMessage":"signature check failed for ${artifact} — partial download deleted","messagePattern":"signature check failed for (.+?) — partial download deleted","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/binary-installer/installer.mjs","lineNumber":217,"sourceCode":"  }\n  const expected = expectedDigest(checksums, artifact);\n  mkdirSync(binDir, { recursive: true });\n  // Per-process part path, and NO pre-unlink. A fixed `${target}.part` plus a\n  // cleanup() immediately before an O_CREAT|O_EXCL open made the exclusivity\n  // guard unreachable: two concurrent installs (npx -y caveman-mcp is registered\n  // per MCP session, so several agents can start one at once) raced — B unlinked\n  // A's directory entry and created its own inode, A hashed ITS OWN bytes and\n  // matched, and then the PATH-based chmod+rename published B's half-written file\n  // as \"checksum verified\". Both the chmod and the rename now act on a name only\n  // this process can own.\n  //\n  // ponytail: a SIGKILL mid-download now leaves one stray .part behind instead of\n  // reusing the fixed name. Sweep binDir for stale .part files if that ever shows\n  // up in the wild.\n  const part = `${target}.${process.pid}.${randomBytes(6).toString(\"hex\")}.part`;\n  try {\n    const actual = await download(`${release}/${artifact}`, part, timeout);\n    if (actual !== expected) throw new Error(`signature check failed for ${artifact} — partial download deleted`);\n    chmodSync(part, 0o755);\n    await replaceWithRetry(part, target);\n  } catch (error) {\n    cleanup(part);\n    throw error;\n  }\n  process.stderr.write(`${name}  ${os}/${arch}  checksum verified\\n`);\n  return target;\n}\n","sourceCodeStart":199,"sourceCodeEnd":227,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/binary-installer/installer.mjs#L199-L227","documentation":"After streaming the artifact into a uniquely named .part file, `download()` returns the sha256 of what was written; `ensureBinary` compares it to the digest from the signed manifest. On mismatch it throws this error and the catch block deletes the .part file, so a corrupted or truncated download can never be promoted to the install target.","triggerScenarios":"Calling `ensureBinary()` where `download(release/artifact, part, timeout)` returns a hash differing from `expected` — truncated download (connection dropped mid-stream), CDN serving a stale/partial artifact, disk corruption, or an artifact replaced on the server after checksums.txt was signed.","commonSituations":"Flaky hotel/VPN networks cutting large downloads short; CDN edge serving an old artifact revision; interrupted resume logic in a middlebox; concurrent download tools corrupting disk sectors (rare).","solutions":["Simply retry the install — the .part file is deleted and the next attempt uses a fresh unique name, so retrying is safe.","Check network stability (wired connection, disable VPN/proxy) if retries keep failing.","Verify the server-side artifact actually matches checksums.txt: `sha256sum <artifact>` after a manual download.","If the server artifact is genuinely wrong, report the release and use an earlier working release, or install the binary manually via the envVar override."],"exampleFix":"// before: repeated corrupt download over flaky network\nawait ensureBinary({ name: \"caveman-mcp\", envVar: \"CAVEMAN_MCP_BIN\" });\n// after: retry with backoff\nfor (let i = 0; i < 3; i++) {\n  try { await ensureBinary({ name: \"caveman-mcp\", envVar: \"CAVEMAN_MCP_BIN\" }); break; }\n  catch (e) { if (i === 2) throw e; await new Promise(r => setTimeout(r, 2 ** i * 1000)); }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function installWithRetry(opts, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await ensureBinary(opts); }\n    catch (e) {\n      if (!String(e.message).includes(\"partial download deleted\") || i === attempts - 1) throw e;\n      await new Promise(r => setTimeout(r, 2 ** i * 500));\n    }\n  }\n}","preventionTips":["Ensure stable connectivity for large downloads; avoid flaky VPNs during install.","Retries are safe: each attempt uses a fresh unique .part name and deletes failed parts.","Verify server-side artifacts match checksums.txt after release publication.","Monitor CDN for stale object caching after releases."],"tags":["checksum","download","integrity"],"backgroundTag":"checksum-mismatch","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}