{"record":{"id":"93579e48f993cb27","repo":"affaan-m/ECC","slug":"invalid-install-state-label-details","errorCode":null,"errorMessage":"Invalid install-state (${label}): ${details}","messagePattern":"Invalid install-state \\((.+?)\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install-lifecycle.js","lineNumber":1871,"sourceCode":"      id: record.adapter.id,\n      target: record.adapter.target,\n      kind: record.adapter.kind,\n      root: record.targetRoot,\n      installStatePath: record.installStatePath\n    }\n  };\n}\n\nfunction assertValidInstallStateForWrite(state, label) {\n  const validation = validateInstallState(state);\n  if (validation.valid) {\n    return;\n  }\n\n  const details = validation.errors\n    .map(error => `${error.instancePath || '/'} ${error.message}`)\n    .join('; ');\n  throw new Error(`Invalid install-state (${label}): ${details}`);\n}\n\nfunction writeRefreshedInstallState(record, statePreview) {\n  const trustedStatePreview = buildAdapterDerivedStatePreview(statePreview, record);\n  const stateWithCurrentDigests = {\n    ...trustedStatePreview,\n    operations: (trustedStatePreview.operations || []).map(operation => {\n      if (!operation.destinationPath) {\n        return { ...operation };\n      }\n      try {\n        const contentSha256 = crypto.createHash('sha256')\n          .update(readFileNoFollow(operation.destinationPath))\n          .digest('hex');\n        return { ...operation, contentSha256 };\n      } catch (_error) {\n        const { contentSha256: _staleDigest, ...operationWithoutDigest } = operation;\n        return operationWithoutDigest;","sourceCodeStart":1853,"sourceCodeEnd":1889,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-lifecycle.js#L1853-L1889","documentation":"The persisted install-state failed schema validation. The message includes a label identifying which state blob was validated and details of each validation error (JSON path + message from the validator's errors array).","triggerScenarios":"Loading an install-state record whose `state` does not conform to the expected schema — missing required fields, wrong types, unexpected extra/renamed properties after a version change.","commonSituations":"Manually editing the state file; state written by a different installer version; truncated or corrupted state after a crash; hand-crafted state for testing.","solutions":["Compare the reported instancePath details against the state schema and fix the offending fields","Delete the invalid state and reinstall to regenerate a valid one","Align installer versions so writer and validator agree on the schema","Restore the state file from a backup taken before the corruption"],"exampleFix":"// before: state missing request field\n{ \"operations\": [...] }\n// after: conforming to schema\n{ \"request\": { \"legacyMode\": false }, \"operations\": [...] }","handlingStrategy":"validation","validationCode":"const validation = validateInstallState(record.state);\nif (validation.errors?.length) {\n  console.error(validation.errors.map(e => `${e.instancePath || '/'} ${e.message}`).join('; '));\n  throw new Error('fix install-state before proceeding');\n}","typeGuard":"function isValidInstallState(state) { return validateInstallState(state).errors == null || validateInstallState(state).errors.length === 0; }","tryCatchPattern":"try { loadAndUseState(record); } catch (e) { if (String(e.message).startsWith('Invalid install-state')) { await reinstallToRegenerateState(); } else throw e; }","preventionTips":["Never hand-edit install-state files","Keep installer versions aligned with the schema validator","Validate state after any external tool touches it"],"tags":["install","validation","schema","state"],"backgroundTag":"schema-validation-failed","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"}