affaan-m/ECC · error · Error

record requires --state and --path

Error message

record requires --state and --path

What it means

The 'record' subcommand of legacy-sync-state.js requires both the --state flag (path to the sync state file created by 'begin') and --path (the file path to record); this fires in main when either readFlag lookup returns empty.

Solutions

  1. Invoke with both flags: record --state <stateFile> --path <installedPath>.
  2. Use the state file path returned by the 'begin' command.
  3. Fix the caller if it drops the path for empty values.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at scripts/codex/legacy-sync-state.js:36 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/3bf5314970c54df7. Report an issue: GitHub.

Appendix: source

Thrown at scripts/codex/legacy-sync-state.js:36

function main(argv = process.argv.slice(2)) {
  const command = argv[0];
  if (command === 'begin') {
    const codexHome = readFlag(argv, '--codex-home');
    const backupDir = readFlag(argv, '--backup-dir');
    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]');

View on GitHub (pinned to 8321021c54)