abhigyanpatwari/GitNexus · warning

[cfg] ${pf.filePath}: CFG emission failed (${err instanceof

Error message

[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) — this file's CFG is partial or absent

What it means

In the scope-resolution pipeline, after a file's functions are walked, their CFG (BasicBlock nodes, CFG edges, REACHING_DEF facts) is emitted into the graph inside a last-resort per-file try/catch. A throw mid-emit warns '[cfg] ${pf.filePath}: CFG emission failed ... this file's CFG is partial or absent' and costs only that file's CFG; the comment notes addNode is not transactional, so BasicBlock nodes inserted before the throw may linger in the graph orphaned but inert. A JSON-representability predicate upstream is supposed to keep bad shapes from ever reaching this path.

Source

Thrown at gitnexus/src/core/ingestion/scope-resolution/pipeline/run.ts:1542

              // Same fact cap the taint-side RD solve uses (coverage parity).
              taintLimits.maxFacts && taintLimits.maxFacts > 0
                ? taintLimits.maxFacts
                : DEFAULT_PDG_MAX_REACHING_DEF_FACTS_PER_FUNCTION,
              rdSolve,
            );
            harvestedSummaries.push(...harvest.summaries);
            summaryUnresolved += harvest.unresolved;
          }
        }
      } catch (err) {
        // Last-resort isolation, mirroring the worker-side per-file try/catch:
        // a shape the predicate misses must cost this one file's CFG, not
        // abort the language's whole scope-resolution pass mid-graph-build.
        // NOTE a mid-emit throw can leave this file's already-inserted
        // BasicBlock nodes in the graph (addNode is not transactional) —
        // orphaned but inert; the predicate keeps every JSON-representable
        // bad shape from reaching this path at all.
        logger.warn(
          `[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) — ` +
            `this file's CFG is partial or absent`,
        );
      }
    }
    if (cfgBlocks > 0) {
      logger.debug(
        `[scope-resolution] CFG emit (lang=${provider.language}): ` +
          `${cfgBlocks} BasicBlock nodes, ${cfgEdges} CFG edges` +
          (cfgDroppedEdges > 0 ? `, ${cfgDroppedEdges} edges dropped (per-function cap)` : '') +
          `; ${rdEdges} REACHING_DEF edges (${rdFacts} facts)` +
          (rdDropped > 0 ? `, ${rdDropped} REACHING_DEF edges dropped (per-function cap)` : '') +
          (rdTruncated > 0 ? `, ${rdTruncated} function(s) hit the fact limit` : '') +
          `; ${cdgEdges} CDG edges` +
          (cdgDropped > 0 ? `, ${cdgDropped} CDG edges dropped (per-function cap)` : '') +
          (cdgSkippedUnsound > 0
            ? `, ${cdgSkippedUnsound} function(s) CDG-skipped (EXIT not reachable from all blocks)`
            : '') +

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Capture the (${err.message}) text and the file path from the warning
  2. Rebuild the index for that repo: node .gitnexus/run.cjs analyze --index-only — version-skew orphan nodes are cleared
  3. If reproducible on a clean index, check the provider's emitted payload types against the graph store schema
  4. Treat downstream CFG/PDG answers for that one file as partial or absent (per the AGENTS.md UNKNOWN-risk rule, do not read emptiness as safety)
  5. Report the file plus message upstream — the predicate was supposed to intercept this shape
Defensive patterns

Strategy: fallback

Try / catch

try {
  emitFileCfg(pf, builder, harvest); // addNode/addEdge for this file's CFG
} catch (err) {
  logger.warn(`[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) - this file's CFG is partial or absent`);
}

Prevention

When it happens

Trigger: Emission failing for one file: a provider emitting a node/edge payload the store rejects (non-JSON-representable value the predicate missed), per-function edge-cap bookkeeping breaking on an exotic function shape, or a version skew between a stored graph and the emitting code.

Common situations: After upgrading the package with a pre-existing .gitnexus index built by an older emitter; changes to a language provider's CFG emit format; files whose function shapes pass the predicate but fail at addNode/addEdge serialization.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-08-20). Data as JSON: /api/errors/1dc34be9c510e542. Report an issue: GitHub.