{"record":{"id":"0811c0a6b2382dfb","repo":"abhigyanpatwari/GitNexus","slug":"cfg-dart-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] Dart buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Dart buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/dart.ts","lineNumber":1094,"sourceCode":"      builder.edge(blk, builder.exitIndex, 'return');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const walk = new DartCfgWalk(builder, harvest);\n    const res = block ? walk.visitSeq(block.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] Dart buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/**\n * Whether a node is a Dart function this visitor builds a CFG for: a\n * `function_body` whose previous sibling is a signature (top-level fn / method /\n * getter / setter / constructor), or a `function_expression` (a closure).\n */\nfunction isFunction(node: SyntaxNode): boolean {\n  if (node.type === 'function_expression') return true;\n  if (node.type !== 'function_body') return false;\n  const prev = node.previousSibling;\n  return prev !== null && DART_SIGNATURE_TYPES.has(prev.type);\n}\n\n/** The Dart CFG visitor. */\nexport function createDartCfgVisitor(): CfgVisitor<SyntaxNode> {","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/dart.ts#L1076-L1112","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Dart tree-sitter visitor. buildFunctionCfg wraps the body walk in a catch-all: any throw from an unexpected or malformed AST shape is logged with console.warn and only that function's CFG is skipped (returns undefined), protecting the file's whole language group ('R4' isolation). Functions covered include function_body nodes preceded by a signature (top-level functions, methods, getters, setters, constructors) and function_expression closures.","triggerScenarios":"A construct inside a Dart function body the walker does not model: Dart 3 pattern constructs, unusual cascade sections, closure bodies with shapes visitSeq does not expect, or ERROR/MISSING nodes from parsing syntactically broken code, causing an internal throw during the walk.","commonSituations":"Grammar version drift between vendored tree-sitter-dart and the visitor; indexing code with syntax errors; generated Dart (json_serializable/protobuf output) with node shapes the walker mishandles; skipping optional grammars at install then re-enabling them with a stale build.","solutions":["Read the ${String(err)} portion of the warning to identify the thrown exception","Index just the affected file and inspect the tree-sitter node types around the failing function","Align grammar and visitor: reinstall deps (rebuilds/sources vendored grammars) or patch the Dart visitor for the node type","Re-run analyze --index-only to rebuild the CFG","Accept the skip if unfixable — only that function loses its CFG"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen before indexing: reject files whose parse produced errors\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip: this function has no CFG","preventionTips":["Reinstall deps after upgrading so the optional Dart grammar matches the visitor","Avoid indexing Dart files with syntax errors or unusual generated shapes","Report the failing node shape (from the warn's err text) upstream","Remember closures (function_expression) are also walked — test small repros for both kinds"],"tags":["cfg","tree-sitter","dart","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"}