affaan-m/ECC · error · Error
finalize requires --state
Error message
finalize requires --state
What it means
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.
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at scripts/codex/legacy-sync-state.js:42 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/e20f3c2ddc3920b7.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/codex/legacy-sync-state.js:42
if (!codexHome || !backupDir) throw new Error('begin requires --codex-home and --backup-dir');
process.stdout.write(`${beginLegacySyncState({
codexHome,
backupDir,
previousHooksPath: readFlag(argv, '--previous-hooks-path') || '',
installedHooksPath: readFlag(argv, '--installed-hooks-path'),
})}\n`);
return;
}
if (command === 'record') {
const statePath = readFlag(argv, '--state');
const filePath = readFlag(argv, '--path');
if (!statePath || !filePath) throw new Error('record requires --state and --path');
recordLegacySyncPath({ statePath, filePath });
return;
}
if (command === 'finalize') {
const statePath = readFlag(argv, '--state');
if (!statePath) throw new Error('finalize requires --state');
finalizeLegacySyncState({ statePath });
return;
}
if (command === 'rollback') {
const statePath = readFlag(argv, '--state');
if (!statePath) throw new Error('rollback requires --state');
const result = rollbackLegacyCodexSync({ statePath });
process.stdout.write(`${JSON.stringify(result)}\n`);
if (result.status !== 'rolled-back') process.exitCode = 1;
return;
}
throw new Error('Usage: legacy-sync-state.js <begin|record|finalize|rollback> [options]');
}
module.exports = { main, readFlag };
if (require.main === module) {
try {View on GitHub (pinned to 8321021c54)