{"record":{"id":"1ab56d3c18ec30d6","repo":"paperclipai/paperclip","slug":"expected-expectedname-opencode-version-rece","errorCode":null,"errorMessage":"Expected ${expectedName}@${OPENCODE_VERSION}, received ${String(packageJson.name)}@${String(packageJson.version)}","messagePattern":"Expected (.+?)@(.+?), received (.+?)@(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/scripts/materialize-opencode-binary.mjs","lineNumber":33,"sourceCode":"\nconst OPENCODE_VERSION = \"1.18.29\";\nconst BASELINE_PACKAGE = \"opencode-linux-x64-baseline\";\n\nfunction readPackage(path) {\n  return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction sha256(path) {\n  return createHash(\"sha256\").update(readFileSync(path)).digest(\"hex\");\n}\n\nfunction assertPackage(packageRoot, expectedName) {\n  const packageJson = readPackage(join(packageRoot, \"package.json\"));\n  if (\n    packageJson.name !== expectedName ||\n    packageJson.version !== OPENCODE_VERSION\n  ) {\n    throw new Error(\n      `Expected ${expectedName}@${OPENCODE_VERSION}, received ${String(packageJson.name)}@${String(packageJson.version)}`,\n    );\n  }\n}\n\nexport function materializePinnedOpenCodeBinary(options = {}) {\n  const platform = options.platform ?? process.platform;\n  const architecture = options.architecture ?? process.arch;\n  if (platform !== \"linux\" || architecture !== \"x64\") {\n    throw new Error(\n      `Pinned OpenCode materialization requires linux/x64, received ${platform}/${architecture}`,\n    );\n  }\n\n  const packageRoot = realpathSync(\n    options.packageRoot ??\n      resolve(import.meta.dirname, \"../node_modules/opencode-ai\"),\n  );","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/scripts/materialize-opencode-binary.mjs#L15-L51","documentation":"assertPackage validates that a materialized package root matches the expected package name and the pinned OPENCODE_VERSION. If package.json's name or version differs, pinned-binary materialization aborts because the source would not be the exact pinned OpenCode build.","triggerScenarios":"Calling assertPackage (directly or via materializePinnedOpenCodeBinary) with a packageRoot whose package.json has a different name than expectedName or whose version is not exactly OPENCODE_VERSION, e.g. after a lockfile update installed a newer opencode-ai.","commonSituations":"Dependency drift from a semver range pulling a newer release; the script pointed at the wrong package root; OPENCODE_VERSION was bumped without updating installed dependencies.","solutions":["Check 'cat <packageRoot>/package.json' and align it to OPENCODE_VERSION, e.g. 'pnpm add opencode-ai@<OPENCODE_VERSION>'.","If OPENCODE_VERSION was intentionally bumped, update the OPENCODE_VERSION constant in materialize-opencode-binary.mjs and the dependency in the same commit.","Verify the script is pointed at the opencode-ai package root, not BASELINE_PACKAGE or another package.","Pin the dependency to an exact version (no ^ or ~) and use --frozen-lockfile in CI."],"exampleFix":"// before\n\"opencode-ai\": \"^1.0.0\"\n// after\n\"opencode-ai\": \"1.0.0\" // exact pin matching OPENCODE_VERSION","handlingStrategy":"validation","validationCode":"const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));\nif (pkg.name !== 'opencode-ai' || pkg.version !== OPENCODE_VERSION) {\n  throw new Error(`pin drift: ${pkg.name}@${pkg.version} != opencode-ai@${OPENCODE_VERSION}`);\n}","typeGuard":"function isPinnedOpencode(pkgJson, expectedName, expectedVersion) {\n  return pkgJson?.name === expectedName && pkgJson?.version === expectedVersion;\n}","tryCatchPattern":"try {\n  materializePinnedOpenCodeBinary();\n} catch (err) {\n  if (String(err.message).startsWith('Expected opencode-ai@')) {\n    execSync(`pnpm add opencode-ai@${OPENCODE_VERSION} --save-exact`);\n    materializePinnedOpenCodeBinary();\n  } else throw err;\n}","preventionTips":["Pin opencode-ai with an exact version (no ^ or ~) in package.json.","Keep the OPENCODE_VERSION constant and the dependency spec in sync in the same commit.","Use --frozen-lockfile in CI to surface pin drift early.","Never point the script at arbitrary package roots."],"tags":["versioning","dependency-management","build"],"backgroundTag":"invalid-argument-value","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}