{"record":{"id":"100a47c916ffc076","repo":"abhigyanpatwari/GitNexus","slug":"cfg-pf-filepath-skipped-cfgs-length-well","errorCode":null,"errorMessage":"[cfg] ${pf.filePath}: skipped ${cfgs.length - wellFormed.length} malformed cfgSideChannel element(s) (bad shape, missing id-anchor fields, or edge endpoints matching no block) — CFG for those functions omitted","messagePattern":"\\[cfg\\] (.+?): skipped (.+?) malformed cfgSideChannel element\\(s\\) \\(bad shape, missing id-anchor fields, or edge endpoints matching no block\\) — CFG for those functions omitted","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/scope-resolution/pipeline/run.ts","lineNumber":1390,"sourceCode":"      // into the Vue context pass) would re-emit identical ids from the same\n      // cfgSideChannel — the dedup-free streaming sink would double the rows.\n      // Skip it here; the in-memory-graph path needs no skip (its Map dedups).\n      if (input.pdgEmittedFiles !== undefined) {\n        if (input.pdgEmittedFiles.has(pf.filePath)) continue;\n        input.pdgEmittedFiles.add(pf.filePath);\n      }\n      try {\n        // Per-element emit-safety filter (mirrors the parsedfile-store\n        // reviver's POLICY: valid elements in a mixed array still emit; junk\n        // is warned and skipped). isEmitSafeCfg lives in cfg/emit.ts next to\n        // the id templating it defends — see its doc for why anchor-field and\n        // endpoint-membership checks are load-bearing. Runs INSIDE the try so\n        // even a predicate-time throw (e.g. a hostile getter) is isolated.\n        const wellFormed = (cfgs as readonly (FunctionCfg | undefined | null)[]).filter(\n          isEmitSafeCfg,\n        );\n        if (wellFormed.length < cfgs.length) {\n          logger.warn(\n            `[cfg] ${pf.filePath}: skipped ${cfgs.length - wellFormed.length} malformed ` +\n              `cfgSideChannel element(s) (bad shape, missing id-anchor fields, or edge ` +\n              `endpoints matching no block) — CFG for those functions omitted`,\n          );\n        }\n        if (wellFormed.length === 0) continue;\n        // U3 hook (#2227): the resolved-callee-id map for this file is\n        // `calleeIdAccumulator?.get(pf.filePath)` — joined here by exact\n        // call-site position to emit `BasicBlock.calleeIds`. Captured above at\n        // the three CALLS emit paths (U2); wired into `emitFileCfgs` by U3.\n        const emitted = emitFileCfgs(\n          pdgTarget,\n          wellFormed,\n          input.pdgMaxEdgesPerFunction ?? DEFAULT_MAX_CFG_EDGES_PER_FUNCTION,\n          // Log cap-overflow drops UNCONDITIONALLY (not via input.onWarn, which is\n          // gated behind the semantic-model validator and silent in production) so\n          // the per-function edge cap never truncates the CFG silently (R6/KTD6).\n          (message) => logger.warn(message),","sourceCodeStart":1372,"sourceCodeEnd":1408,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/ingestion/scope-resolution/pipeline/run.ts#L1372-L1408","documentation":"When emitting per-function CFGs from the persisted cfgSideChannel, each element is validated by isEmitSafeCfg (shape, id-anchor fields, edge endpoints must match real blocks). Elements failing the predicate are warned and skipped — CFG for those functions is simply omitted, while valid elements in the same array still emit (same policy as the parsedfile-store reviver).","triggerScenarios":"Emit-phase CFG emission (pdgTarget configured) where a file's cfgSideChannel contains malformed elements: wrong shape, missing id-anchor fields needed by the id templating, or edges whose endpoints match no block. wellFormed.length < cfgs.length triggers the warn naming the file and count.","commonSituations":"A corrupted or partially-written .gitnexus parsed-file store (interrupted index), a store written by an older CLI version with a different cfgSideChannel schema, hand-modified index artifacts, or a producer bug that serialized cfg elements with missing anchor fields.","solutions":["Delete the stale index (.gitnexus store) and run a full re-analyze so the side-channel is regenerated by the current producer","Check for version skew — make sure the same CLI version wrote and reads the store (npx gitnexus@latest vs a pinned older install)","If it recurs on a fresh index, capture the file path from the warn and report it upstream with that file — a producer emitting non-emit-safe elements is a bug (isEmitSafeCfg exists to defend the id templating)","Confirm recovery by re-running a pdg_query on the affected functions and checking CFG results appear"],"exampleFix":"# before\nnpx gitnexus analyze   # warn: skipped N malformed cfgSideChannel element(s) for src/foo.ts\n# after\nrm -rf .gitnexus\nnpx gitnexus analyze   # store regenerated; warn gone","handlingStrategy":"validation","validationCode":"// Validate a persisted store before relying on its CFG coverage:\n// after analyze, query a known function and fail if CFG is absent.\nconst r = await pdgQuery({ mode: 'controls', target: 'src/foo.ts:myFn' });\nif (r.results.length === 0 && analyzeLog.includes('malformed cfgSideChannel')) {\n  await rebuildIndexFromScratch(); // rm -rf .gitnexus && re-analyze\n}","typeGuard":"// Mirror of the emit-safety predicate for side-channel consumers:\nfunction isEmitSafeCfgLike(c: unknown): c is { id: string; blocks: unknown[]; edges: unknown[] } {\n  return (\n    typeof c === 'object' && c !== null &&\n    typeof (c as any).id === 'string' && (c as any).id.length > 0 &&\n    Array.isArray((c as any).blocks) && Array.isArray((c as any).edges)\n  );\n}","tryCatchPattern":null,"preventionTips":["Never mix CLI versions against one .gitnexus store — re-analyze after upgrades","Interrupted index runs are the top corruption source; treat any prior SIGKILL during analyze as a reason to re-index","Fail CI on 'malformed cfgSideChannel' warnings rather than accepting silently reduced CFG coverage"],"tags":["cfg","pdg","serialization","index-corruption","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}