abhigyanpatwari/GitNexus · error · Error

Invoked analyzer artifact is absent from the validated build

Error message

Invoked analyzer artifact is absent from the validated build: ${invokedArtifactPath}

What it means

Thrown by resolveAnalyzerRunnerIdentity when the invoked analyzer artifact path (derived from process.argv[1] if it is inside buildRoot, else the analyzerModulePath) is not found among the validated build entries. cachedBuildDigestForPath returns null when the path is not isInside(buildRoot) or no build entry of kind 'file' matches its relative path. The identity cannot be issued without a digest for the very module being executed.

Source

Thrown at gitnexus/src/core/analyzer-identity.ts:2769

    packageVersion,
    buildKind: kind,
    buildCanonicalization: BUILD_CANONICALIZATION,
    dependencyCanonicalization: DEPENDENCY_RUNTIME_CANONICALIZATION,
    traversalLimits,
    runtimeVariant,
    buildRootState: build.rootState,
    buildDigest: build.digest,
    buildEntries: build.entries,
    buildDirectoryGuards: build.directoryGuards,
    dependencyIdentity: dependency.identity,
    dependencyFileGuards: dependencyFileGuards(dependencyInputs),
    dependencyDirectoryGuards: dependencyDirectoryGuards(dependencyInputs),
    dependencyPathGuards: dependencyPathGuards(dependencyInputs),
    artifactEntries: dependency.entries,
  };
  const invokedDigest = cachedBuildDigestForPath(nextCache, invokedArtifactPath);
  if (!invokedDigest) {
    throw new Error(
      `Invoked analyzer artifact is absent from the validated build: ${invokedArtifactPath}`,
    );
  }
  const identity: AnalyzerRunnerIdentity = {
    schemaVersion: ANALYZER_RUNNER_IDENTITY_SCHEMA_VERSION,
    runtime: runnerRuntimeIdentity(runtimeVariant),
    cliVersion: packageVersion,
    invokedArtifact: {
      path: invokedArtifactPath,
      digest: invokedDigest,
    },
    build: {
      kind,
      rootPath: buildRoot,
      canonicalization: BUILD_CANONICALIZATION,
      digest: build.digest,
    },
    dependencyRuntime: dependency.identity,

View on GitHub (pinned to d540b00184)

Solutions

  1. Invoke the analyzer from its built artifact, not its source: `node dist/cli.js` (or the published bin) instead of `tsx src/cli.ts`.
  2. Confirm invokedArtifactPath is inside buildRoot: `node -e "console.log(require('path').relative('<buildRoot>','<artifact>'))"` should yield a non-`..` relative path.
  3. Rebuild so the artifact exists in the build output: `npm run build` then retry.
  4. If using a symlinked bin, ensure the resolved real path still lies under buildRoot.

Example fix

// before: invoking source via tsx
//   $ tsx gitnexus/src/cli.ts analyze
//   -> "Invoked analyzer artifact is absent from the validated build: /repo/gitnexus/src/cli.ts"
//
// after: invoke the built artifact
//   $ npm --prefix gitnexus run build
//   $ node gitnexus/dist/cli.js analyze
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('node:fs');
const path = require('node:path');
function assertInvokedArtifactInBuild(buildRoot, analyzerModuleUrl) {
  const { fileURLToPath } = require('node:url');
  const analyzerPath = path.resolve(fileURLToPath(analyzerModuleUrl));
  const buildResolved = path.resolve(buildRoot);
  const rel = path.relative(buildResolved, analyzerPath);
  if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) {
    throw new Error(`Analyzer module ${analyzerPath} is not under build root ${buildResolved}; invoke the built artifact.`);
  }
  const st = fs.lstatSync(analyzerPath);
  if (!st.isFile()) throw new Error(`${analyzerPath} is not a regular file`);
}
// assertInvokedArtifactInBuild(buildRoot, import.meta.url);

Prevention

When it happens

Trigger: After the build is hashed and the nextCache assembled, cachedBuildDigestForPath(nextCache, invokedArtifactPath) is called. It returns null if invokedArtifactPath is outside buildRoot, or if its relativePath does not match any buildEntries file (e.g. the entry was pruned, the path points at a source file outside the build output, or buildRoot was mis-resolved).

Common situations: Invoking the analyzer from its TypeScript source (via tsx/ts-node) so analyzerModulePath points at `src/...` while buildRoot was resolved as `dist/`; running a stale shim whose target moved; a buildRoot that was resolved from a symlinked location so isInside returns false; an artifact path with a `..` traversal that resolves outside buildRoot; running the analyzer after `tsc` but pointing at the pre-build source.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/4702d82867cc30bc. Report an issue: GitHub.