abhigyanpatwari/GitNexus · warning
[cfg] Python buildFunctionCfg skipped a function in
Error message
[cfg] Python buildFunctionCfg skipped a function in ${filePath}: ${String(err)} What it means
During indexing GitNexus builds a per-function control-flow graph (CFG) with a Python tree-sitter visitor (PY_FUNCTION_TYPES). buildFunctionCfg wraps the body walk (visitSeq over the body's namedChildren minus comments) in a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that function's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).
Solutions
- Read the ${String(err)} portion of the warning for the underlying exception
- Index only the affected file, then inspect the tree around the failing def/lambda
- Reinstall dependencies to resync the grammar or patch the Python visitor for the node type
- Re-run analyze --index-only to rebuild the CFG layer
- Accept the skip — the rest of the file indexes normally
Defensive patterns
Strategy: fallback
Validate before calling
// prescreen: tree-sitter marks invalid Python with ERROR/MISSING nodes if (tree.rootNode.hasError) fixSourceOrExclude(file);
Try / catch
const cfg = visitor.buildFunctionCfg(fn, ctx); if (cfg === undefined) continue; // warned skip: def/lambda without CFG
Prevention
- Do not index files mid-edit with syntax errors
- Resync the Python grammar on upgrades
- Reproduce match/decorator/async shapes on a single file when reporting
- Treat absent CFG as UNKNOWN risk in impact decisions
When it happens
Trigger: A Python construct the walker does not model: structural pattern matching (match/case), decorated async bodies, walrus-heavy expressions, or ERROR/MISSING nodes when tree-sitter parses invalid Python, causing a throw during visitSeq.
Common situations: Grammar version drift between the Python grammar and the visitor; indexing files mid-edit with syntax errors; notebooks or generated Python with unusual indentation node shapes; newer CPython syntax the visitor predates.
Related errors
- [cfg] C# buildFunctionCfg skipped a function in
- [cfg] Dart buildFunctionCfg skipped a function in
- [cfg] Go buildFunctionCfg skipped a function in
- [cfg] Java buildFunctionCfg skipped a function in
- [cfg] Kotlin buildFunctionCfg skipped a function in
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/9bb8df8ba1fffe4a.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/core/ingestion/cfg/visitors/python.ts:760
builder.edge(builder.entryIndex, blk, 'seq');
builder.edge(blk, builder.exitIndex, 'return');
return builder.finish(harvest.bindingTable());
}
const walk = new PythonCfgWalk(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] Python buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
return undefined;
}
}
/** Whether a node is a Python function this visitor builds a CFG for. */
function isFunction(node: SyntaxNode): boolean {
return PY_FUNCTION_TYPES.has(node.type);
}
/** The Python CFG visitor. */
export function createPythonCfgVisitor(): CfgVisitor<SyntaxNode> {
return { buildFunctionCfg, isFunction };
}
export { PY_FUNCTION_TYPES };
View on GitHub (pinned to aac7515d2a)