{"record":{"id":"60f5e434c0ce534b","repo":"abhigyanpatwari/GitNexus","slug":"cfg-kotlin-buildfunctioncfg-skipped-a-function-i","errorCode":null,"errorMessage":"[cfg] Kotlin buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Kotlin buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/kotlin.ts","lineNumber":1037,"sourceCode":"      builder.edge(builder.entryIndex, builder.exitIndex, 'seq');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const walk = new KotlinCfgWalk(builder, harvest);\n    const res = body ? walk.visitSeq(body.namedChildren.filter((c) => !isComment(c))) : null;\n\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] Kotlin buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Kotlin function/lambda this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return KOTLIN_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Kotlin CFG visitor. */\nexport function createKotlinCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { KOTLIN_FUNCTION_TYPES };\n","sourceCodeStart":1019,"sourceCodeEnd":1053,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/kotlin.ts#L1019-L1053","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: skip indexing files that do not parse cleanly\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip: function or lambda without CFG","preventionTips":["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"],"tags":["cfg","tree-sitter","kotlin","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"}