{"record":{"id":"0867d65e2696e4d9","repo":"abhigyanpatwari/GitNexus","slug":"cfg-c-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] C# buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] C# buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/csharp.ts","lineNumber":1138,"sourceCode":"      builder.edge(builder.entryIndex, blk, 'seq');\n      builder.edge(blk, builder.exitIndex, 'return');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const walk = new CsharpCfgWalk(builder, harvest);\n    const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));\n    if (!res) {\n      builder.edge(builder.entryIndex, builder.exitIndex, 'seq'); // empty body\n      return builder.finish(harvest.bindingTable());\n    }\n    builder.edge(builder.entryIndex, res.entry, 'seq');\n    builder.connect(res.exits, builder.exitIndex, 'seq'); // normal fall-off → EXIT\n    return builder.finish(harvest.bindingTable());\n  } catch (err) {\n    // Never throw out of buildFunctionCfg — a malformed AST shape must skip only\n    // this one function's CFG, never drop the whole file's language group (R4).\n    // eslint-disable-next-line no-console\n    console.warn(`[cfg] C# buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a C# function this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return CSHARP_FUNCTION_TYPES.has(node.type);\n}\n\n/** The C# CFG visitor. */\nexport function createCsharpCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { CSHARP_FUNCTION_TYPES };\n","sourceCodeStart":1120,"sourceCodeEnd":1154,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/csharp.ts#L1120-L1154","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a C# tree-sitter visitor. buildFunctionCfg wraps the whole body walk (visitSeq over the body's namedChildren minus comments) in a catch-all: any throw caused by an unexpected or malformed AST shape is logged with console.warn and only that one function's CFG is skipped (returns undefined), so a bad function never drops the whole file's language group (the 'R4' isolation rule named in the comment). This is a degradation warning, not a crash: the rest of the file still indexes.","triggerScenarios":"A statement or construct inside a C# function body that the visitor's walk does not model: a grammar node kind the dispatch does not cover, an ERROR/MISSING node produced when tree-sitter parses syntactically broken code, or a node whose expected named child is absent so an internal invariant throws during visitSeq.","commonSituations":"Vendored tree-sitter-c-sharp grammar version drifting from the node types the visitor was written against; indexing files with syntax errors or unbalanced preprocessor regions; indexing generated/minified C#; newer C# syntax the walker has not learned yet.","solutions":["Read the ${String(err)} portion of the warning — it names the exact exception thrown by the walker","Reproduce by indexing only that file (single-path analyze) and dump the function's tree-sitter node types to find the unhandled shape","Reinstall dependencies so the vendored grammar matches the package version, or patch the C# visitor to handle the offending node type","Re-run node .gitnexus/run.cjs analyze --index-only to rebuild the CFG layer","If unfixable, accept the degradation: that function gets no CFG/PDG answers but the file's other symbols index normally"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import { parseSourceSafe } from './safe-parse';\n// prescreen: tree-sitter flags ERROR/MISSING nodes on the root\nif (tree.rootNode.hasError) {\n  fixSourceOrExclude(file); // broken syntax is the most common skip cause\n}","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) {\n  // the visitor already warned; treat as 'no CFG for this function'\n  continue;\n}","preventionTips":["Keep the vendored tree-sitter-c-sharp grammar in sync with the package (rebuild node_modules after upgrades)","Do not index generated/minified C# or files with known syntax errors","Watch for bursts of this warn on one file — it signals grammar/visitor mismatch worth reporting upstream","Treat missing CFG answers for the function as UNKNOWN, not as safe"],"tags":["cfg","tree-sitter","csharp","ingestion","graceful-degradation"],"backgroundTag":"tree-sitter-unknown-node-type","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}