{"record":{"id":"f40e39f15deca2e2","repo":"affaan-m/ECC","slug":"no-install-state-available-for-repair","errorCode":null,"errorMessage":"No install-state available for repair","messagePattern":"No install-state available for repair","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install-lifecycle.js","lineNumber":1808,"sourceCode":"      okCount: 0,\n      errorCount: 0,\n      warningCount: 0\n    }\n  );\n\n  return {\n    generatedAt: new Date().toISOString(),\n    packageVersion: context.packageVersion,\n    manifestVersion: context.manifestVersion,\n    results,\n    summary\n  };\n}\n\nfunction createRepairPlanFromRecord(record, context, options = {}) {\n  const state = record.state;\n  if (!state) {\n    throw new Error('No install-state available for repair');\n  }\n\n  if (\n    record.legacyLayout !== 'opencode'\n    && (state.request.legacyMode || shouldRepairFromRecordedOperations(state))\n  ) {\n    const operations = hydrateRecordedOperations(\n      context.repoRoot,\n      getManagedOperations(state),\n      record.targetRoot\n    );\n    const statePreview = buildRecordedStatePreview(state, context, operations);\n\n    return {\n      mode: state.request.legacyMode ? 'legacy' : 'recorded',\n      target: record.adapter.target,\n      adapter: record.adapter,\n      targetRoot: state.target.root,","sourceCodeStart":1790,"sourceCodeEnd":1826,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-lifecycle.js#L1790-L1826","documentation":"createRepairPlanFromRecord requires the record to contain a saved `state` object; without it there are no recorded operations from which to build a repair plan, so repair is impossible and this error is thrown.","triggerScenarios":"Calling the repair flow with a record object that has state === null/undefined — e.g. a record loaded from an install that never persisted state, or a freshly created/empty record.","commonSituations":"Repairing before the first completed install; state file deleted or corrupted; reading a legacy record that predates state persistence.","solutions":["Run a fresh install so a complete install-state is persisted, then repair","Point the repair flow at the correct record containing saved state","Restore the install-state file from backup","If legacy layout is 'opencode', use the legacy repair path instead"],"exampleFix":"// before\nconst plan = createRepairPlanFromRecord({ legacyLayout: 'npm' });\n// after\nconst plan = record.state\n  ? createRepairPlanFromRecord(record)\n  : createRepairPlanFromFreshInstall(manifest);","handlingStrategy":"validation","validationCode":"if (!record?.state) throw new Error('record has no install-state; run install first');","typeGuard":"function hasInstallState(record) { return record != null && record.state != null && typeof record.state === 'object'; }","tryCatchPattern":"try { createRepairPlanFromRecord(record); } catch (e) { if (e.message === 'No install-state available for repair') { await freshInstallThenRepair(); } else throw e; }","preventionTips":["Only repair records that completed an install with persisted state","Back up install-state files","Detect legacy 'opencode' layout and use legacy repair path"],"tags":["install","repair","missing-state"],"backgroundTag":"record-not-found","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}