{"record":{"id":"f1c0833dfd0f770e","repo":"abhigyanpatwari/GitNexus","slug":"cfg-java-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] Java buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Java buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/java.ts","lineNumber":1093,"sourceCode":"      builder.edge(builder.entryIndex, blk, 'seq');\n      builder.edge(blk, builder.exitIndex, 'return');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const walk = new JavaCfgWalk(builder, harvest);\n    const res = walk.visitSeq(body.namedChildren.filter((c) => !isComment(c)));\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] Java buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Java function this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return JAVA_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Java CFG visitor. */\nexport function createJavaCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { JAVA_FUNCTION_TYPES };\n","sourceCodeStart":1075,"sourceCodeEnd":1109,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/java.ts#L1075-L1109","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Java tree-sitter visitor. buildFunctionCfg wraps the body walk (visitSeq over namedChildren filtered by isComment) 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), so one malformed function cannot drop the file's language group ('R4' isolation).","triggerScenarios":"A Java construct inside a method/constructor body the walker does not model: newer switch-expression or pattern-matching shapes, annotation-heavy declarations, or ERROR/MISSING nodes from syntactically broken code, causing an internal invariant to throw during the walk.","commonSituations":"Vendored tree-sitter-java grammar drift versus the visitor's handled node types; indexing code with syntax errors; generated Java (RPC stubs, builders) with exotic node shapes; very new JDK syntax the visitor predates.","solutions":["Read the ${String(err)} portion of the warning to find the thrown error","Reproduce on the single file and inspect the failing function's node types","Resync grammar and visitor via reinstall, or patch the Java visitor to cover the node type","Re-run analyze --index-only to rebuild the CFG","Accept the skip — only that function lacks a CFG"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: ERROR nodes from invalid Java are the usual skip trigger\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip for this method","preventionTips":["Fix syntax errors in indexed Java sources","Resync grammar/visitor on package upgrades","Prefer framework-idiomatic Java over exotic syntax in code being indexed","Collect the warn's err text when reporting coverage gaps"],"tags":["cfg","tree-sitter","java","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"}