{"record":{"id":"56b2b16db185851a","repo":"nanocoai/nanoclaw","slug":"no-version-field-in-pkgpath","errorCode":null,"errorMessage":"No version field in ${pkgPath}","messagePattern":"No version field in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/upgrade-state.ts","lineNumber":41,"sourceCode":"  tree: string;\n  updatedAt: string;\n  via: string;\n}\n\nexport interface CodeIdentity {\n  version: string;\n  commit: string;\n  tree: string;\n}\n\nconst MARKER_PATH = path.join(DATA_DIR, 'upgrade-state.json');\nconst FIX_COMMAND = 'pnpm exec tsx scripts/upgrade-state.ts set';\n\n/** Version the running code declares, read from package.json. */\nexport function getCodeVersion(projectRoot: string = process.cwd()): string {\n  const pkgPath = path.join(projectRoot, 'package.json');\n  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) as { version?: string };\n  if (!pkg.version) throw new Error(`No version field in ${pkgPath}`);\n  return pkg.version;\n}\n\n/** Git identity of the exact checkout the host is about to run. */\nexport function getCodeIdentity(projectRoot: string = process.cwd()): CodeIdentity {\n  const git = (rev: string): string =>\n    execFileSync('git', ['rev-parse', '--verify', rev], {\n      cwd: projectRoot,\n      encoding: 'utf8',\n      stdio: ['ignore', 'pipe', 'ignore'],\n    }).trim();\n\n  const version = getCodeVersion(projectRoot);\n  try {\n    return { version, commit: git('HEAD'), tree: git('HEAD^{tree}') };\n  } catch {\n    return { version, commit: 'unknown', tree: 'unknown' };\n  }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/upgrade-state.ts#L23-L59","documentation":"Error \"No version field in ${pkgPath}\" thrown in nanocoai/nanoclaw.","triggerScenarios":"Thrown at src/upgrade-state.ts:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}