{"record":{"id":"9bb8df8ba1fffe4a","repo":"abhigyanpatwari/GitNexus","slug":"cfg-python-buildfunctioncfg-skipped-a-function-i","errorCode":null,"errorMessage":"[cfg] Python buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] Python buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/python.ts","lineNumber":760,"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 PythonCfgWalk(builder, harvest);\n    const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));\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] Python buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a Python function this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return PY_FUNCTION_TYPES.has(node.type);\n}\n\n/** The Python CFG visitor. */\nexport function createPythonCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { PY_FUNCTION_TYPES };\n","sourceCodeStart":742,"sourceCodeEnd":776,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/python.ts#L742-L776","documentation":"During indexing GitNexus builds a per-function control-flow graph (CFG) with a Python tree-sitter visitor (PY_FUNCTION_TYPES). buildFunctionCfg wraps the body walk (visitSeq over the body's namedChildren minus comments) 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 Python construct the walker does not model: structural pattern matching (match/case), decorated async bodies, walrus-heavy expressions, or ERROR/MISSING nodes when tree-sitter parses invalid Python, causing a throw during visitSeq.","commonSituations":"Grammar version drift between the Python grammar and the visitor; indexing files mid-edit with syntax errors; notebooks or generated Python with unusual indentation node shapes; newer CPython syntax the visitor predates.","solutions":["Read the ${String(err)} portion of the warning for the underlying exception","Index only the affected file, then inspect the tree around the failing def/lambda","Reinstall dependencies to resync the grammar or patch the Python visitor for the node type","Re-run analyze --index-only to rebuild the CFG layer","Accept the skip — the rest of the file indexes normally"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: tree-sitter marks invalid Python with ERROR/MISSING nodes\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip: def/lambda without CFG","preventionTips":["Do not index files mid-edit with syntax errors","Resync the Python grammar on upgrades","Reproduce match/decorator/async shapes on a single file when reporting","Treat absent CFG as UNKNOWN risk in impact decisions"],"tags":["cfg","tree-sitter","python","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-14T05:17:10.506Z"}