{"record":{"id":"62787b2f99ca582d","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-package-version-is-unavailable-in-packa","errorCode":null,"errorMessage":"GitNexus package version is unavailable in ${packageRoot}","messagePattern":"GitNexus package version is unavailable in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2729,"sourceCode":"        rememberIdentityCache(previousCache);\n        return cachedIdentity;\n      }\n    }\n  }\n\n  const build = hashBuildTree(buildRoot, previousCache, options, traversalLimits);\n  const dependencyInputs = collectDependencyInputs(packageRoot, options, traversalLimits);\n  const dependencySnapshotBefore = dependencySnapshot(dependencyInputs);\n  const dependency = hashDependencyRuntime(\n    dependencyInputs,\n    previousCache,\n    options,\n    runtimeVariant,\n  );\n\n  const packageVersion = dependencyInputs.packages[0]?.manifest.version;\n  if (typeof packageVersion !== 'string' || packageVersion.trim() === '') {\n    throw new Error(`GitNexus package version is unavailable in ${packageRoot}`);\n  }\n\n  const buildSnapshotAfter = buildSnapshot(\n    collectBuildEntries(buildRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(build.snapshot, buildSnapshotAfter)) {\n    throw new Error(`Analyzer build changed while its identity was being computed: ${buildRoot}`);\n  }\n  const dependencySnapshotAfter = dependencySnapshot(\n    collectDependencyInputs(packageRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(dependencySnapshotBefore, dependencySnapshotAfter)) {\n    throw new Error(\n      `Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}`,\n    );\n  }\n\n  const nextCache: IdentityCachePayload = {","sourceCodeStart":2711,"sourceCodeEnd":2747,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/analyzer-identity.ts#L2711-L2747","documentation":"Thrown after dependency collection when the root package's manifest (dependencyInputs.packages[0].manifest, i.e. the packageRoot's own package.json) has no usable string `version` field. The analyzer identity embeds the package version as cliVersion, so an absent or non-string version is a hard failure rather than a silent placeholder.","triggerScenarios":"resolveAnalyzerRunnerIdentity reads dependencyInputs.packages[0].manifest.version; if `typeof version !== 'string'` or `version.trim() === ''`, the throw fires naming packageRoot. Triggered by a root package.json missing the `version` field, with `\"version\": \"\"`, or with `\"version\": null` / a numeric literal.","commonSituations":"A private workspace root whose package.json omits `version` (some monorepo templates do this for the aggregate root); a package.json hand-edited and the version line deleted; a JSON5/JSON-with-comments file where a tool stripped the field; a CI build that templates package.json and left version blank; `\"version\": 1.2.3` (numeric, not string).","solutions":["Add a string version to the root package.json: `\"version\": \"0.0.0\"` (private packages may use any semver-ish string).","Validate before running: `node -e \"const p=require('./package.json'); if(typeof p.version!=='string'||!p.version.trim())throw 1\"`.","If the root is genuinely versionless by convention, give it a placeholder version and document it.","Ensure your build templating never emits a non-string or empty version."],"exampleFix":"// before: package.json\n//   { \"name\": \"my-repo\", \"private\": true }\n//   -> \"GitNexus package version is unavailable in /repo\"\n//\n// after:\n//   { \"name\": \"my-repo\", \"private\": true, \"version\": \"0.0.0\" }","handlingStrategy":"validation","validationCode":"function assertRootPackageVersion(packageRoot) {\n  const fs = require('node:fs');\n  const path = require('node:path');\n  const manifest = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));\n  if (typeof manifest.version !== 'string' || manifest.version.trim() === '') {\n    throw new Error(`Root package.json must have a non-empty string \"version\"; got ${JSON.stringify(manifest.version)}`);\n  }\n}\n// assertRootPackageVersion(process.cwd());","typeGuard":"function hasStringVersion(manifest) {\n  return typeof manifest?.version === 'string' && manifest.version.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always include a `\"version\": \"x.y.z\"` string in the root package.json (private packages may use \"0.0.0\").","Validate templated package.json in CI before invoking the analyzer.","Ensure `\"version\"` is a JSON string, not a number (`\"1.2.3\"` not `1.2.3`).","Run a pre-flight check on the manifest in your analyzer bootstrap."],"tags":["analyzer-identity","manifest","package-json","configuration"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}