{"record":{"id":"9fccc56d217f16cb","repo":"abhigyanpatwari/GitNexus","slug":"group-skipping-corrupt-contract-row-in-contracts","errorCode":null,"errorMessage":"[group] skipping corrupt contract row in contracts.json","messagePattern":"\\[group\\] skipping corrupt contract row in contracts\\.json","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/group/service.ts","lineNumber":314,"sourceCode":"\n  if (!root || typeof root !== 'object' || Array.isArray(root)) {\n    return { ok: false, error: 'contracts.json has an invalid root object' };\n  }\n\n  const base = root as Record<string, unknown>;\n  const contractsRaw = base.contracts;\n  const crossRaw = base.crossLinks;\n  let skippedCorrupt = 0;\n\n  const contracts: StoredContract[] = [];\n  if (Array.isArray(contractsRaw)) {\n    for (const row of contractsRaw) {\n      try {\n        if (isStoredContract(row)) {\n          contracts.push(row);\n        } else {\n          skippedCorrupt++;\n          logger.warn('[group] skipping corrupt contract row in contracts.json');\n        }\n      } catch {\n        skippedCorrupt++;\n        logger.warn('[group] skipping corrupt contract row in contracts.json');\n      }\n    }\n  }\n\n  const crossLinks: CrossLink[] = [];\n  if (Array.isArray(crossRaw)) {\n    for (const row of crossRaw) {\n      try {\n        if (isCrossLink(row)) {\n          crossLinks.push(row);\n        } else {\n          skippedCorrupt++;\n          logger.warn('[group] skipping corrupt crossLinks row in contracts.json');\n        }","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/group/service.ts#L296-L332","documentation":"Emitted while resiliently loading a group's contracts.json (loadContractRegistryResilient). A row in the top-level contracts array failed the isStoredContract shape check — string contractId/type/repo/symbolUid/symbolName, role of 'provider' or 'consumer', numeric confidence, and object meta and symbolRef (with filePath and name strings). The row is counted in skippedCorrupt and dropped while the rest of the registry loads normally.","triggerScenarios":"contracts.json contains a row whose fields are missing or of the wrong type: a crash/kill during group sync left a partially written file, the file was hand-edited, or an older/newer GitNexus version wrote a different StoredContract schema.","commonSituations":"Interrupted group_sync leaving truncated-but-parseable JSON; upgrading GitNexus across a StoredContract schema change; external tooling appending rows to contracts.json.","solutions":["Re-run group sync to regenerate contracts.json from current indexes","If corruption persists, delete the group's contracts.json and re-analyze the group","If a custom tool writes contracts.json, align its rows with the StoredContract shape (contractId, type, repo, role, symbolUid, symbolName, confidence, meta, symbolRef.filePath, symbolRef.name)"],"exampleFix":"// before — corrupt row in contracts.json\n{ \"contractId\": \"c1\", \"type\": \"http\", \"repo\": \"api\", \"role\": \"providr\" }\n\n// after — shape-valid row\n{ \"contractId\": \"c1\", \"type\": \"http\", \"repo\": \"api\", \"role\": \"provider\",\n  \"symbolUid\": \"uid:1\", \"symbolName\": \"handler\", \"confidence\": 0.9,\n  \"meta\": {}, \"symbolRef\": { \"filePath\": \"src/a.ts\", \"name\": \"handler\" } }","handlingStrategy":"type-guard","validationCode":"// Pre-flight: validate contracts.json rows before loading the registry\nimport { readFileSync } from 'node:fs';\nconst registry = JSON.parse(readFileSync('contracts.json', 'utf8'));\nconst bad = (registry.contracts ?? []).filter((r: unknown) => !isStoredContract(r));\nif (bad.length > 0) {\n  throw new Error(`${bad.length} contract row(s) failed the StoredContract shape — regenerate via group sync`);\n}","typeGuard":"function isStoredContract(raw: unknown): raw is StoredContract {\n  if (!raw || typeof raw !== 'object') return false;\n  const o = raw as Record<string, unknown>;\n  return (\n    typeof o.contractId === 'string' &&\n    typeof o.type === 'string' &&\n    typeof o.repo === 'string' &&\n    (o.role === 'provider' || o.role === 'consumer') &&\n    typeof o.symbolUid === 'string' &&\n    typeof o.symbolName === 'string' &&\n    typeof o.confidence === 'number' &&\n    o.meta !== undefined && typeof o.meta === 'object' && o.meta !== null &&\n    o.symbolRef !== undefined && typeof o.symbolRef === 'object' && o.symbolRef !== null &&\n    typeof (o.symbolRef as Record<string, unknown>).filePath === 'string' &&\n    typeof (o.symbolRef as Record<string, unknown>).name === 'string'\n  );\n}","tryCatchPattern":null,"preventionTips":["Treat contracts.json as generated state — regenerate with group sync instead of editing it","Never kill a group sync mid-write; let it finish or use its cancellation path","After upgrading GitNexus, regenerate contracts.json to pick up the current schema"],"tags":["group","contracts-json","schema","corrupt-row","contract-registry"],"backgroundTag":"schema-validation-failed","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}