abhigyanpatwari/GitNexus · warning
[cfg] Ruby buildFunctionCfg skipped a function in ${filePath
Error message
[cfg] Ruby buildFunctionCfg skipped a function in ${filePath}: ${String(err)} What it means
During indexing GitNexus builds a per-function control-flow graph (CFG) with a Ruby tree-sitter visitor (RUBY_FUNCTION_TYPES covers methods and closures). Unlike the visitSeq-based visitors, Ruby walks the whole body via walk.visitStmt(body) inside a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that method/closure's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).
Source
Thrown at gitnexus/src/core/ingestion/cfg/visitors/ruby.ts:993
// For a bare block / lambda, a `redo` re-enters the block body. The body's
// first block is the NEXT index the builder will allocate (entry + exit are
// already taken). Set it so a top-level `redo` inside the block loops back.
if (fnNode.type !== 'method' && fnNode.type !== 'singleton_method') {
walk.setBlockRedoTarget(builder.blockCount);
}
const res = walk.visitStmt(body);
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] Ruby buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
return undefined;
}
}
/** Whether a node is a Ruby function/closure this visitor builds a CFG for. */
function isFunction(node: SyntaxNode): boolean {
return RUBY_FUNCTION_TYPES.has(node.type);
}
/** The Ruby CFG visitor. */
export function createRubyCfgVisitor(): CfgVisitor<SyntaxNode> {
return { buildFunctionCfg, isFunction };
}
export { RUBY_FUNCTION_TYPES };
View on GitHub (pinned to aac7515d2a)
Solutions
- Read the ${String(err)} portion of the warning to find the thrown error
- Reproduce on the single file and inspect the failing method's node shapes
- Resync grammar and visitor (reinstall deps) or patch the Ruby visitor
- Re-run analyze --index-only to rebuild the CFG
- Accept the skip — only that method/closure lacks a CFG
Defensive patterns
Strategy: fallback
Validate before calling
// prescreen: invalid Ruby parses with ERROR nodes on the root if (tree.rootNode.hasError) fixSourceOrExclude(file);
Try / catch
const cfg = visitor.buildFunctionCfg(fn, ctx); if (cfg === undefined) continue; // warned skip for this method/closure
Prevention
- Fix syntax errors before indexing
- Flag endless methods / pattern-matching bodies when reporting skips
- Keep grammar and visitor aligned after upgrades
- Remember Ruby walks via visitStmt on the whole body — repros should minimize the body, not the class
When it happens
Trigger: A Ruby construct visitStmt does not model: endless method definitions, pattern-matching (in/case-right) bodies, complex block/proc chains, safe-navigation heavy expressions, or ERROR/MISSING nodes from syntactically invalid Ruby.
Common situations: Grammar drift in the Ruby grammar versus the visitor; indexing highly metaprogrammed code; files with syntax errors; very new Ruby syntax (e.g. endless defs, it block param) the walker predates.
Related errors
- [cfg] C# buildFunctionCfg skipped a function in ${filePath}:
- [cfg] Dart buildFunctionCfg skipped a function in ${filePath
- [cfg] Go buildFunctionCfg skipped a function in ${filePath}:
- [cfg] Java buildFunctionCfg skipped a function in ${filePath
- [cfg] Kotlin buildFunctionCfg skipped a function in ${filePa
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/78c10e9c717f6617.
Report an issue: GitHub.