abhigyanpatwari/GitNexus · warning
[cfg] Kotlin buildFunctionCfg skipped a function in ${filePa
Error message
[cfg] Kotlin buildFunctionCfg skipped a function in ${filePath}: ${String(err)} What it means
During indexing GitNexus builds a per-function control-flow graph (CFG) with a Kotlin tree-sitter visitor (KOTLIN_FUNCTION_TYPES covers functions and lambdas). buildFunctionCfg wraps the body walk in a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that function/lambda's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).
Source
Thrown at gitnexus/src/core/ingestion/cfg/visitors/kotlin.ts:1037
builder.edge(builder.entryIndex, builder.exitIndex, 'seq');
return builder.finish(harvest.bindingTable());
}
const walk = new KotlinCfgWalk(builder, harvest);
const res = body ? walk.visitSeq(body.namedChildren.filter((c) => !isComment(c))) : null;
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] Kotlin buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
return undefined;
}
}
/** Whether a node is a Kotlin function/lambda this visitor builds a CFG for. */
function isFunction(node: SyntaxNode): boolean {
return KOTLIN_FUNCTION_TYPES.has(node.type);
}
/** The Kotlin CFG visitor. */
export function createKotlinCfgVisitor(): CfgVisitor<SyntaxNode> {
return { buildFunctionCfg, isFunction };
}
export { KOTLIN_FUNCTION_TYPES };
View on GitHub (pinned to aac7515d2a)
Solutions
- Read the ${String(err)} portion of the warning for the exact exception
- Index just the affected file and dump the node types around the failing function/lambda
- Rebuild the vendored kotlin grammar (reinstall deps; note GITNEXUS_SKIP_OPTIONAL_GRAMMARS must not have excluded it) or patch the visitor
- Re-run analyze --index-only to rebuild the CFG
- Accept the skip if the shape cannot be fixed locally
Defensive patterns
Strategy: fallback
Validate before calling
// prescreen: skip indexing files that do not parse cleanly if (tree.rootNode.hasError) fixSourceOrExclude(file);
Try / catch
const cfg = visitor.buildFunctionCfg(fn, ctx); if (cfg === undefined) continue; // warned skip: function or lambda without CFG
Prevention
- Ensure the optional Kotlin grammar was installed (do not skip it via GITNEXUS_SKIP_OPTIONAL_GRAMMARS when Kotlin coverage matters)
- Kotlin support is recent — report uncovered coroutine/when shapes
- Rebuild node_modules after Node or package upgrades
- Treat missing CFG answers as UNKNOWN
When it happens
Trigger: A Kotlin construct the walker does not model: coroutine suspend bodies, complex when-subject expressions, trailing-lambda or companion-object shapes with missing expected children, or ERROR/MISSING nodes from invalid source, causing a throw during the walk.
Common situations: Kotlin was added to MIGRATED_LANGUAGES recently (changelog 1.8.0), so newer syntax shapes may be uncovered; vendored tree-sitter-kotlin is an optional grammar — a stale or source-built copy can drift from the visitor; indexing files with syntax errors.
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] PHP buildFunctionCfg skipped a function in ${filePath}
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/60f5e434c0ce534b.
Report an issue: GitHub.