{"record":{"id":"a96b388872dff019","repo":"abhigyanpatwari/GitNexus","slug":"cfg-rust-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] Rust buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Rust buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/rust.ts","lineNumber":715,"sourceCode":"      const res = walk.visitStmt(body);\n      builder.edge(builder.entryIndex, res ? res.entry : builder.exitIndex, 'seq');\n      builder.connect(res ? res.exits : [builder.entryIndex], builder.exitIndex, 'seq');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const res = walk.visitSeq(body.namedChildren.filter(isNotComment));\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] Rust buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Rust function/closure this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return RUST_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Rust CFG visitor. */\nexport function createRustCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { RUST_FUNCTION_TYPES };\n","sourceCodeStart":697,"sourceCodeEnd":731,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/rust.ts#L697-L731","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Rust tree-sitter visitor (RUST_FUNCTION_TYPES covers functions and closures). buildFunctionCfg wraps the body walk (visitSeq over namedChildren filtered by isNotComment) in a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that function/closure's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).","triggerScenarios":"A Rust construct the walker does not model: macro-invocation bodies (macro_rules!/derive-generated shapes), complex match arms, async/await chains, or ERROR/MISSING nodes from syntactically invalid Rust, causing a throw during the walk.","commonSituations":"Indexing macro-heavy codebases (embedded SQL, serde derives) whose token trees the walker mishandles; grammar drift in the Rust grammar; files with syntax errors; generated Rust (bindgen output, cargo expand artifacts).","solutions":["Read the ${String(err)} portion of the warning for the exact exception","Index just the affected file and inspect the macro/expression node shapes","Resync grammar and visitor via reinstall, or patch the Rust visitor for the shape","Re-run analyze --index-only to rebuild the CFG","Accept the skip — only that function's CFG is absent"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: macro soup and invalid Rust parse with ERROR nodes\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip: fn/closure without CFG","preventionTips":["Exclude cargo-expand artifacts and heavily generated Rust from indexing","Report macro-invocation shapes that trip the walker","Resync grammar/visitor on upgrades","Treat missing CFG as UNKNOWN, not unused"],"tags":["cfg","tree-sitter","rust","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"}