{"record":{"id":"4702d82867cc30bc","repo":"abhigyanpatwari/GitNexus","slug":"invoked-analyzer-artifact-is-absent-from-the-valid","errorCode":null,"errorMessage":"Invoked analyzer artifact is absent from the validated build: ${invokedArtifactPath}","messagePattern":"Invoked analyzer artifact is absent from the validated build: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2793,"sourceCode":"    packageVersion,\n    buildKind: kind,\n    buildCanonicalization: BUILD_CANONICALIZATION,\n    dependencyCanonicalization: DEPENDENCY_RUNTIME_CANONICALIZATION,\n    traversalLimits,\n    runtimeVariant,\n    buildRootState: build.rootState,\n    buildDigest: build.digest,\n    buildEntries: build.entries,\n    buildDirectoryGuards: build.directoryGuards,\n    dependencyIdentity: dependency.identity,\n    dependencyFileGuards: dependencyFileGuards(dependencyInputs),\n    dependencyDirectoryGuards: dependencyDirectoryGuards(dependencyInputs),\n    dependencyPathGuards: dependencyPathGuards(dependencyInputs),\n    artifactEntries: dependency.entries,\n  };\n  const invokedDigest = cachedBuildDigestForPath(nextCache, invokedArtifactPath);\n  if (!invokedDigest) {\n    throw new Error(\n      `Invoked analyzer artifact is absent from the validated build: ${invokedArtifactPath}`,\n    );\n  }\n  const identity: AnalyzerRunnerIdentity = {\n    schemaVersion: ANALYZER_RUNNER_IDENTITY_SCHEMA_VERSION,\n    runtime: runnerRuntimeIdentity(runtimeVariant),\n    cliVersion: packageVersion,\n    invokedArtifact: {\n      path: invokedArtifactPath,\n      digest: invokedDigest,\n    },\n    build: {\n      kind,\n      rootPath: buildRoot,\n      canonicalization: BUILD_CANONICALIZATION,\n      digest: build.digest,\n    },\n    dependencyRuntime: dependency.identity,","sourceCodeStart":2775,"sourceCodeEnd":2811,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/analyzer-identity.ts#L2775-L2811","documentation":"The runner identity must pin the digest of the exact artifact (CLI entry module) currently being executed. That digest is looked up in the freshly computed cache of build entries; if invokedArtifactPath has no cached digest, the running code is not part of the build tree that was just validated — meaning the process is executing from somewhere other than the validated installation (or path canonicalization mismatched).","triggerScenarios":"resolveAnalyzerRunnerIdentity(analyzerModuleUrl, ...) where the module URL resolves to a path absent from the validated build entries: running from a stray copy of the CLI (npx cache of an old version, a moved directory), import.meta.url disagreeing with the on-disk build layout after a reinstall, or a symlinked bin shim pointing outside the hashed build root.","commonSituations":"npx running a stale cached package while a new version was installed globally, upgrading gitnexus while a long-lived MCP server/session still references old files, or invoking through a custom wrapper that loads the module from a copied tree.","solutions":["Restart the CLI/MCP session so it loads from the current install (old handles keep old paths alive).","Clear the npx cache and invoke the installed binary directly: npm install -g gitnexus@latest && gitnexus analyze.","Remove duplicate/stray copies of the package so exactly one install is on disk.","Avoid launching via symlinked shims that resolve outside the real package tree."],"exampleFix":"# before: npx uses a stale cache after an upgrade\nnpx gitnexus analyze\n# Invoked analyzer artifact is absent from the validated build: /home/u/.npm/_npx/.../dist/cli.js\n\n# after: run the freshly installed global binary\nnpx clear-npx-cache 2>/dev/null || rm -rf ~/.npm/_npx\nnpm install -g gitnexus@latest\ngitnexus analyze","handlingStrategy":"fallback","validationCode":"// Before spawning, confirm the module you invoke belongs to the install you think:\nimport { realpathSync } from 'node:fs';\nfunction moduleInsideInstall(modulePath: string, installRoot: string): boolean {\n  const real = realpathSync(modulePath);\n  return real.startsWith(realpathSync(installRoot) + '/');\n}\nif (!moduleInsideInstall(cliEntry, installRoot)) await reinstallPublishedRelease();","typeGuard":null,"tryCatchPattern":"try {\n  await analyze({ repo: '.' });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('absent from the validated build')) {\n    // Stale handle on an upgraded install: restart the process and use the installed binary\n    throw new Error('Restart the CLI/MCP session; it is executing from a removed artifact');\n  }\n  throw err;\n}","preventionTips":["Invoke the installed binary (gitnexus ...) rather than npx after upgrades; clear the npx cache when versions flip-flop.","Restart MCP servers and long-lived sessions after upgrading gitnexus.","Keep exactly one copy of the package on disk per machine/user.","Avoid custom symlinked launchers that resolve outside the real package tree."],"tags":["analyzer-identity","installation","stale-cache","npx"],"backgroundTag":"stale-install-mismatch","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}