{"record":{"id":"3bf5314970c54df7","repo":"affaan-m/ECC","slug":"record-requires-state-and-path","errorCode":null,"errorMessage":"record requires --state and --path","messagePattern":"record requires --state and --path","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/codex/legacy-sync-state.js","lineNumber":36,"sourceCode":"\nfunction main(argv = process.argv.slice(2)) {\n  const command = argv[0];\n  if (command === 'begin') {\n    const codexHome = readFlag(argv, '--codex-home');\n    const backupDir = readFlag(argv, '--backup-dir');\n    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]');","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/codex/legacy-sync-state.js#L18-L54","documentation":"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.","triggerScenarios":"Thrown at scripts/codex/legacy-sync-state.js:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke with both flags: record --state <stateFile> --path <installedPath>.","Use the state file path returned by the 'begin' command.","Fix the caller if it drops the path for empty values."],"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"}