{"record":{"id":"20a5dfecc4082ddd","repo":"abhigyanpatwari/GitNexus","slug":"cfg-go-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] Go buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Go buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/go.ts","lineNumber":873,"sourceCode":"\n    const paramFacts = harvest.paramFacts();\n    if (paramFacts) builder.attachFacts(builder.entryIndex, paramFacts);\n\n    const walk = new GoCfgWalk(builder, harvest);\n    const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));\n\n    builder.edge(builder.entryIndex, res ? res.entry : builder.exitIndex, 'seq');\n    // Normal fall-off threads through the active `defer` chain (LIFO) → EXIT.\n    const normalExits = res ? res.exits : [builder.entryIndex];\n    const afterDefers = walk.finishDefers(normalExits);\n    builder.connect(afterDefers, builder.exitIndex, 'seq');\n    walk.flushGotos(builder);\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] Go buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Go function this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return GO_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Go CFG visitor. */\nexport function createGoCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { GO_FUNCTION_TYPES };\n","sourceCodeStart":855,"sourceCodeEnd":889,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/go.ts#L855-L889","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Go tree-sitter visitor. buildFunctionCfg wraps the walk — including defer-chain threading (walk.finishDefers, LIFO) and goto flushing (walk.flushGotos) — 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).","triggerScenarios":"A Go function body containing a construct the walker does not model: complex goto/label shapes, generic (type-parameterized) function bodies with unexpected node kinds, or ERROR/MISSING nodes from syntactically invalid source, causing a throw during visitSeq or the defer/goto bookkeeping.","commonSituations":"Indexing huge generated .pb.go protobuf stubs with unusual shapes; grammar version drift in vendored tree-sitter-go; files with syntax errors; newer Go language features the visitor predates.","solutions":["Read the ${String(err)} portion of the warning for the underlying exception","Index only the affected file and inspect its parse tree around the failing function","Reinstall dependencies to resync the vendored grammar, or patch the Go visitor for the shape","Re-run analyze --index-only to rebuild the CFG layer","Accept the skip: only that function's CFG (including its defer threading) is absent"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: catch ERROR/MISSING nodes before the CFG walk\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip; defer/goto threading lost for this fn","preventionTips":["Exclude giant generated .pb.go stubs from indexing","Keep the Go grammar and visitor versions aligned via clean reinstalls","Flag goto-heavy or generic-heavy functions when reproducing skips","Treat absent CFG for the function as UNKNOWN risk, not unused"],"tags":["cfg","tree-sitter","go","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"}