{"record":{"id":"e20f3c2ddc3920b7","repo":"affaan-m/ECC","slug":"finalize-requires-state","errorCode":null,"errorMessage":"finalize requires --state","messagePattern":"finalize requires --state","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/codex/legacy-sync-state.js","lineNumber":42,"sourceCode":"    if (!codexHome || !backupDir) throw new Error('begin requires --codex-home and --backup-dir');\n    process.stdout.write(`${beginLegacySyncState({\n      codexHome,\n      backupDir,\n      previousHooksPath: readFlag(argv, '--previous-hooks-path') || '',\n      installedHooksPath: readFlag(argv, '--installed-hooks-path'),\n    })}\\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 {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/codex/legacy-sync-state.js#L24-L60","documentation":"The 'finalize' subcommand of legacy-sync-state.js needs the --state flag pointing at the sync state file to commit; thrown from main when readFlag(argv, '--state') finds no value.","triggerScenarios":"Thrown at scripts/codex/legacy-sync-state.js:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the state file path: finalize --state <stateFile>.","Run 'begin' first if no state file exists yet.","Confirm the state file path survived between installer steps."],"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"}