{"record":{"id":"78c10e9c717f6617","repo":"abhigyanpatwari/GitNexus","slug":"cfg-ruby-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] Ruby buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Ruby buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/ruby.ts","lineNumber":993,"sourceCode":"    // For a bare block / lambda, a `redo` re-enters the block body. The body's\n    // first block is the NEXT index the builder will allocate (entry + exit are\n    // already taken). Set it so a top-level `redo` inside the block loops back.\n    if (fnNode.type !== 'method' && fnNode.type !== 'singleton_method') {\n      walk.setBlockRedoTarget(builder.blockCount);\n    }\n    const res = walk.visitStmt(body);\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] Ruby buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Ruby function/closure this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return RUBY_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Ruby CFG visitor. */\nexport function createRubyCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { RUBY_FUNCTION_TYPES };\n","sourceCodeStart":975,"sourceCodeEnd":1009,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/ruby.ts#L975-L1009","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Ruby tree-sitter visitor (RUBY_FUNCTION_TYPES covers methods and closures). Unlike the visitSeq-based visitors, Ruby walks the whole body via walk.visitStmt(body) inside a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that method/closure's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).","triggerScenarios":"A Ruby construct visitStmt does not model: endless method definitions, pattern-matching (in/case-right) bodies, complex block/proc chains, safe-navigation heavy expressions, or ERROR/MISSING nodes from syntactically invalid Ruby.","commonSituations":"Grammar drift in the Ruby grammar versus the visitor; indexing highly metaprogrammed code; files with syntax errors; very new Ruby syntax (e.g. endless defs, it block param) the walker predates.","solutions":["Read the ${String(err)} portion of the warning to find the thrown error","Reproduce on the single file and inspect the failing method's node shapes","Resync grammar and visitor (reinstall deps) or patch the Ruby visitor","Re-run analyze --index-only to rebuild the CFG","Accept the skip — only that method/closure lacks a CFG"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: invalid Ruby parses with ERROR nodes on the root\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip for this method/closure","preventionTips":["Fix syntax errors before indexing","Flag endless methods / pattern-matching bodies when reporting skips","Keep grammar and visitor aligned after upgrades","Remember Ruby walks via visitStmt on the whole body — repros should minimize the body, not the class"],"tags":["cfg","tree-sitter","ruby","ingestion","graceful-degradation"],"backgroundTag":"tree-sitter-unknown-node-type","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}