{"record":{"id":"39e60221833357a1","repo":"affaan-m/ECC","slug":"invalid-install-state-label-label","errorCode":null,"errorMessage":"Invalid install-state${label ? ` (${label})` : ''}: ${formatValidationErrors(result.errors)}","messagePattern":"Invalid install-state(.+?)\\)` : ''\\}: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install-state.js","lineNumber":232,"sourceCode":"function formatValidationErrors(errors = []) {\n  return errors\n    .map(error => `${error.instancePath || '/'} ${error.message}`)\n    .join('; ');\n}\n\nfunction validateInstallState(state) {\n  const validator = getValidator();\n  const valid = validator(state);\n  return {\n    valid,\n    errors: validator.errors || [],\n  };\n}\n\nfunction assertValidInstallState(state, label) {\n  const result = validateInstallState(state);\n  if (!result.valid) {\n    throw new Error(`Invalid install-state${label ? ` (${label})` : ''}: ${formatValidationErrors(result.errors)}`);\n  }\n}\n\nfunction createInstallState(options) {\n  const installedAt = options.installedAt || new Date().toISOString();\n  const state = {\n    schemaVersion: 'ecc.install.v1',\n    installedAt,\n    target: {\n      id: options.adapter.id,\n      target: options.adapter.target || undefined,\n      kind: options.adapter.kind || undefined,\n      root: options.targetRoot,\n      installStatePath: options.installStatePath,\n    },\n    request: {\n      profile: options.request.profile || null,\n      modules: Array.isArray(options.request.modules) ? [...options.request.modules] : [],","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install-state.js#L214-L250","documentation":"Thrown by assertValidInstallState() when the hand-rolled validator (createFallbackValidator) returns errors against the ecc.install.v1 schema. The validator enforces required fields, no additional properties, and primitive types — mirroring schemas/install-state.schema.json. The message lists every AJAX-style instancePath/message pair via formatValidationErrors.","triggerScenarios":"An install-state file that is missing schemaVersion, target, request, resolution, source, or operations; has extra top-level keys; has wrong-typed fields (e.g. installedAt is a number); was written by an older/newer ECC version with a different schema.","commonSituations":"Cross-version migration: an older ECC wrote a state file the new validator rejects; a fork hand-edited the JSON; a third-party tool produced a near-miss file.","solutions":["Read the full validation error list — each entry's instancePath points at the offending field.","Delete the file and rerun the installer to regenerate a schema-conformant state.","If migrating, write a small transform that adds/removes keys to match ecc.install.v1.","Compare against createInstallState() output in install-state.js:236 for the canonical shape."],"exampleFix":"// before — state file missing request field\n{ \"schemaVersion\": \"ecc.install.v1\", \"target\": {}, \"resolution\": {}, \"source\": {}, \"operations\": [] }\n// after\n{\n  \"schemaVersion\": \"ecc.install.v1\",\n  \"installedAt\": \"2025-01-01T00:00:00.000Z\",\n  \"target\": { \"id\": \"claude\", \"root\": \"/\" },\n  \"request\": { \"profile\": \"baseline\", \"modules\": [], \"includeComponents\": [], \"excludeComponents\": [], \"legacyLanguages\": [], \"legacyMode\": false },\n  \"resolution\": { \"selectedModules\": [], \"skippedModules\": [] },\n  \"source\": { \"repoVersion\": null, \"repoCommit\": null, \"manifestVersion\": null },\n  \"operations\": []\n}","handlingStrategy":"validation","validationCode":"const { validateInstallState } = require('./scripts/lib/install-state');\nconst result = validateInstallState(state);\nif (!result.valid) {\n  // either migrate or discard\n  console.error(result.errors);\n  return null;\n}\n// safe to use state","typeGuard":null,"tryCatchPattern":"try {\n  assertValidInstallState(state, label);\n} catch (err) {\n  if (/^Invalid install-state/.test(err.message)) {\n    // discard and let the installer regenerate\n    fs.rmSync(statePath, { force: true });\n    state = null;\n  } else throw err;\n}","preventionTips":["Always validateInstallState() after reading an install-state file from disk.","Bump schemaVersion and write a migrator when changing the state shape."],"tags":["install-state","validation","schema","json"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}