{"record":{"id":"1dc34be9c510e542","repo":"abhigyanpatwari/GitNexus","slug":"cfg-pf-filepath-cfg-emission-failed-err-i","errorCode":null,"errorMessage":"[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) — this file's CFG is partial or absent","messagePattern":"\\[cfg\\] (.+?): CFG emission failed \\((.+?)\\) — this file's CFG is partial or absent","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/scope-resolution/pipeline/run.ts","lineNumber":1542,"sourceCode":"              // Same fact cap the taint-side RD solve uses (coverage parity).\n              taintLimits.maxFacts && taintLimits.maxFacts > 0\n                ? taintLimits.maxFacts\n                : DEFAULT_PDG_MAX_REACHING_DEF_FACTS_PER_FUNCTION,\n              rdSolve,\n            );\n            harvestedSummaries.push(...harvest.summaries);\n            summaryUnresolved += harvest.unresolved;\n          }\n        }\n      } catch (err) {\n        // Last-resort isolation, mirroring the worker-side per-file try/catch:\n        // a shape the predicate misses must cost this one file's CFG, not\n        // abort the language's whole scope-resolution pass mid-graph-build.\n        // NOTE a mid-emit throw can leave this file's already-inserted\n        // BasicBlock nodes in the graph (addNode is not transactional) —\n        // orphaned but inert; the predicate keeps every JSON-representable\n        // bad shape from reaching this path at all.\n        logger.warn(\n          `[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) — ` +\n            `this file's CFG is partial or absent`,\n        );\n      }\n    }\n    if (cfgBlocks > 0) {\n      logger.debug(\n        `[scope-resolution] CFG emit (lang=${provider.language}): ` +\n          `${cfgBlocks} BasicBlock nodes, ${cfgEdges} CFG edges` +\n          (cfgDroppedEdges > 0 ? `, ${cfgDroppedEdges} edges dropped (per-function cap)` : '') +\n          `; ${rdEdges} REACHING_DEF edges (${rdFacts} facts)` +\n          (rdDropped > 0 ? `, ${rdDropped} REACHING_DEF edges dropped (per-function cap)` : '') +\n          (rdTruncated > 0 ? `, ${rdTruncated} function(s) hit the fact limit` : '') +\n          `; ${cdgEdges} CDG edges` +\n          (cdgDropped > 0 ? `, ${cdgDropped} CDG edges dropped (per-function cap)` : '') +\n          (cdgSkippedUnsound > 0\n            ? `, ${cdgSkippedUnsound} function(s) CDG-skipped (EXIT not reachable from all blocks)`\n            : '') +","sourceCodeStart":1524,"sourceCodeEnd":1560,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/ingestion/scope-resolution/pipeline/run.ts#L1524-L1560","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Capture the (${err.message}) text and the file path from the warning","Rebuild the index for that repo: node .gitnexus/run.cjs analyze --index-only — version-skew orphan nodes are cleared","If reproducible on a clean index, check the provider's emitted payload types against the graph store schema","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)","Report the file plus message upstream — the predicate was supposed to intercept this shape"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  emitFileCfg(pf, builder, harvest); // addNode/addEdge for this file's CFG\n} catch (err) {\n  logger.warn(`[cfg] ${pf.filePath}: CFG emission failed (${err instanceof Error ? err.message : String(err)}) - this file's CFG is partial or absent`);\n}","preventionTips":["Rebuild the index (analyze --index-only) after upgrading the package so emitter and stored graph never skew","Keep the --pdg layer decisions consistent between runs (always on or always off per repo)","Treat CFG/PDG answers for the warned file as partial — apply the UNKNOWN-risk rule, confirm with a text search","Report reproducible cases with the file path and err.message; the upstream predicate should have caught the shape"],"tags":["cfg","scope-resolution","graph","partial-write","ingestion"],"backgroundTag":"cfg-build-failed","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}