{"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":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install-lifecycle.js","lineNumber":1309,"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 (state.request.legacyMode || shouldRepairFromRecordedOperations(state)) {\n    const operations = hydrateRecordedOperations(context.repoRoot, getManagedOperations(state));\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,\n      installRoot: state.target.root,\n      installStatePath: state.target.installStatePath,\n      warnings: [],\n      languages: Array.isArray(state.request.legacyLanguages) ? [...state.request.legacyLanguages] : [],\n      operations,\n      statePreview\n    };","sourceCodeStart":1291,"sourceCodeEnd":1327,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install-lifecycle.js#L1291-L1327","documentation":"createRepairPlanFromRecord reads record.state and refuses to plan a repair when it is null/undefined. Without the recorded install-state there is no list of operations to replay, so the repair cannot know what to restore.","triggerScenarios":"Invoking repair on a target whose install-state file exists but parsed to a record with no `state` field — e.g. the file is `{}`, truncated, or only contains adapter metadata without the operations payload.","commonSituations":"Install-state file was manually emptied or truncated; a prior installer bug wrote only the wrapper object; the state was wiped by an uninstall that removed operations but left the file behind; permission error caused a partial read.","solutions":["Inspect the install-state file at record.installStatePath — confirm it contains a top-level `state` object with `request`, `target`, and `operations`.","If the state is missing or empty, perform a fresh install to regenerate it instead of repairing.","Restore the install-state file from backup if one exists.","Check file permissions/ownership so the installer can read the full file."],"exampleFix":"// before: install-state.json = { \"adapter\": {...} } /* no state */\n// after:\nrm install-state.json\n./install.sh --target claude\n./install.sh --target claude --repair","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction loadRepairableRecord(installStatePath) {\n  const raw = JSON.parse(fs.readFileSync(installStatePath, 'utf8'));\n  if (!raw || typeof raw !== 'object' || !raw.state) {\n    throw new Error('install-state has no `state`; reinstall to regenerate');\n  }\n  return raw;\n}\n// call before repair planning","typeGuard":"function recordHasState(record) {\n  return Boolean(record && typeof record === 'object' && record.state);\n}","tryCatchPattern":"try {\n  plan = createRepairPlanFromRecord(record, ctx);\n} catch (err) {\n  if (err.message === 'No install-state available for repair') {\n    // re-install to regenerate state, then retry repair\n  } else throw err;\n}","preventionTips":["Never blank out the install-state file.","Back up install-state after each successful install.","If you wipe state intentionally, re-install before attempting repair.","Ensure the installer has read permissions on the state file."],"tags":["repair","install","validation","state"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}