{"record":{"id":"3a267fd01bc789cf","repo":"affaan-m/ECC","slug":"begin-requires-codex-home-and-backup-dir","errorCode":null,"errorMessage":"begin requires --codex-home and --backup-dir","messagePattern":"begin requires --codex-home and --backup-dir","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/codex/legacy-sync-state.js","lineNumber":24,"sourceCode":"  finalizeLegacySyncState,\n  recordLegacySyncPath,\n  rollbackLegacyCodexSync,\n} = require('../lib/codex-legacy-sync');\n\nfunction readFlag(args, name) {\n  const index = args.indexOf(name);\n  if (index === -1) return null;\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) return null;\n  return value;\n}\n\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');","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/codex/legacy-sync-state.js#L6-L42","documentation":"main's 'begin' branch throws when either --codex-home or --backup-dir is missing or has no usable value. Legacy sync state must record both the Codex home and the backup location before any migration steps can begin.","triggerScenarios":"Thrown at scripts/codex/legacy-sync-state.js:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call: legacy-sync-state.js begin --codex-home <dir> --backup-dir <dir>.","Ensure flag values do not start with '--' or are absent (readFlag returns null then).","Check the installer script passes both flags."],"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"}