abhigyanpatwari/GitNexus · warning

[cfg] C# buildFunctionCfg skipped a function in ${filePath}:

Error message

[cfg] C# buildFunctionCfg skipped a function in ${filePath}: ${String(err)}

What it means

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.

Source

Thrown at gitnexus/src/core/ingestion/cfg/visitors/csharp.ts:1138

      builder.edge(builder.entryIndex, blk, 'seq');
      builder.edge(blk, builder.exitIndex, 'return');
      return builder.finish(harvest.bindingTable());
    }

    const walk = new CsharpCfgWalk(builder, harvest);
    const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));
    if (!res) {
      builder.edge(builder.entryIndex, builder.exitIndex, 'seq'); // empty body
      return builder.finish(harvest.bindingTable());
    }
    builder.edge(builder.entryIndex, res.entry, 'seq');
    builder.connect(res.exits, builder.exitIndex, 'seq'); // normal fall-off → EXIT
    return builder.finish(harvest.bindingTable());
  } catch (err) {
    // Never throw out of buildFunctionCfg — a malformed AST shape must skip only
    // this one function's CFG, never drop the whole file's language group (R4).
    // eslint-disable-next-line no-console
    console.warn(`[cfg] C# buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
    return undefined;
  }
}

/** Whether a node is a C# function this visitor builds a CFG for. */
function isFunction(node: SyntaxNode): boolean {
  return CSHARP_FUNCTION_TYPES.has(node.type);
}

/** The C# CFG visitor. */
export function createCsharpCfgVisitor(): CfgVisitor<SyntaxNode> {
  return { buildFunctionCfg, isFunction };
}

export { CSHARP_FUNCTION_TYPES };

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Read the ${String(err)} portion of the warning — it names the exact exception thrown by the walker
  2. Reproduce by indexing only that file (single-path analyze) and dump the function's tree-sitter node types to find the unhandled shape
  3. Reinstall dependencies so the vendored grammar matches the package version, or patch the C# visitor to handle the offending node type
  4. Re-run node .gitnexus/run.cjs analyze --index-only to rebuild the CFG layer
  5. If unfixable, accept the degradation: that function gets no CFG/PDG answers but the file's other symbols index normally
Defensive patterns

Strategy: fallback

Validate before calling

import { parseSourceSafe } from './safe-parse';
// prescreen: tree-sitter flags ERROR/MISSING nodes on the root
if (tree.rootNode.hasError) {
  fixSourceOrExclude(file); // broken syntax is the most common skip cause
}

Try / catch

const cfg = visitor.buildFunctionCfg(fn, ctx);
if (cfg === undefined) {
  // the visitor already warned; treat as 'no CFG for this function'
  continue;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20). Data as JSON: /api/errors/0867d65e2696e4d9. Report an issue: GitHub.