{"record":{"id":"7a96bb6decf1a688","repo":"affaan-m/ECC","slug":"rollback-requires-state","errorCode":null,"errorMessage":"rollback requires --state","messagePattern":"rollback requires --state","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/codex/legacy-sync-state.js","lineNumber":48,"sourceCode":"    })}\\n`);\n    return;\n  }\n  if (command === 'record') {\n    const statePath = readFlag(argv, '--state');\n    const filePath = readFlag(argv, '--path');\n    if (!statePath || !filePath) throw new Error('record requires --state and --path');\n    recordLegacySyncPath({ statePath, filePath });\n    return;\n  }\n  if (command === 'finalize') {\n    const statePath = readFlag(argv, '--state');\n    if (!statePath) throw new Error('finalize requires --state');\n    finalizeLegacySyncState({ statePath });\n    return;\n  }\n  if (command === 'rollback') {\n    const statePath = readFlag(argv, '--state');\n    if (!statePath) throw new Error('rollback requires --state');\n    const result = rollbackLegacyCodexSync({ statePath });\n    process.stdout.write(`${JSON.stringify(result)}\\n`);\n    if (result.status !== 'rolled-back') process.exitCode = 1;\n    return;\n  }\n  throw new Error('Usage: legacy-sync-state.js <begin|record|finalize|rollback> [options]');\n}\n\nmodule.exports = { main, readFlag };\n\nif (require.main === module) {\n  try {\n    main();\n  } catch (error) {\n    process.stderr.write(`[ecc-sync] ERROR: ${error.message}\\n`);\n    process.exit(1);\n  }\n}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/codex/legacy-sync-state.js#L30-L66","documentation":"The 'rollback' subcommand of legacy-sync-state.js needs the --state flag identifying the sync state file to restore from; thrown from main when the --state readFlag lookup is empty.","triggerScenarios":"Thrown at scripts/codex/legacy-sync-state.js:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass: rollback --state <stateFile> using the file from 'begin'.","If the state file was deleted, rollback is impossible; restore from the backup directory manually.","Check the installer error path preserved the state path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}