{"record":{"id":"e20f46370302d907","repo":"affaan-m/ECC","slug":"ecc-dry-run-must-be-1-or-0-when-set","errorCode":null,"errorMessage":"ECC_DRY_RUN must be \"1\" or \"0\" when set","messagePattern":"ECC_DRY_RUN must be \"1\" or \"0\" when set","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/uninstall.js","lineNumber":131,"sourceCode":"    for (const retainedPath of result.retainedPaths) console.log(`  - ${retainedPath}`);\n  }\n  for (const warning of result.warnings) console.log(`Warning: ${warning}`);\n}\n\nfunction codexHomePath() {\n  return process.env.CODEX_HOME || path.join(process.env.HOME || os.homedir(), '.codex');\n}\n\n/**\n * Dry-run is enabled either by the subcommand-level `--dry-run` flag or by the\n * global `ecc --dry-run <command>` prefix, which sets ECC_DRY_RUN=1 (#2952).\n * Destructive subcommands must honor both forms rather than silently ignoring\n * the global flag.\n */\nfunction isDryRun(options) {\n  const dryRunEnv = process.env.ECC_DRY_RUN;\n  if (dryRunEnv !== undefined && dryRunEnv !== '0' && dryRunEnv !== '1') {\n    throw new Error('ECC_DRY_RUN must be \"1\" or \"0\" when set');\n  }\n  return options.dryRun || dryRunEnv === '1';\n}\n\nfunction includesCodexTarget(targets) {\n  return targets.length === 0 || targets.includes('codex');\n}\n\nasync function main() {\n  try {\n    const options = parseArgs(process.argv);\n    if (options.help) {\n      showHelp(0);\n    }\n\n    const dryRun = isDryRun(options);\n\n    if (options.legacyCodexSync && options.targets.length > 0) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/uninstall.js#L113-L149","documentation":"scripts/uninstall.js honors the ECC_DRY_RUN environment variable as a global dry-run switch. isDryRun validates that if the variable is set at all, it must be exactly \"0\" or \"1\"; any other value (e.g. \"true\", \"yes\", empty string, or whitespace) throws 'ECC_DRY_RUN must be \"1\" or \"0\" when set'. This protects destructive uninstall operations from ambiguous truthy strings.","triggerScenarios":"Exporting ECC_DRY_RUN=true, ECC_DRY_RUN=yes, ECC_DRY_RUN=\"\" or ECC_DRY_RUN=\" 1\" and then running any uninstall subcommand; isDryRun reads process.env.ECC_DRY_RUN and throws on the invalid value.","commonSituations":".env files or CI pipelines using boolean-style \"true\"/\"false\"; shell rc files exporting the var once with a wrong value affecting all later runs; copy-pasting a snippet intended for a different tool's flag convention.","solutions":["Set ECC_DRY_RUN=1 or ECC_DRY_RUN=0 (exactly) in your shell or .env.","Unset the variable entirely (`unset ECC_DRY_RUN`) if you don't intend a dry run.","Grep shell rc files and CI configs for ECC_DRY_RUN=true and replace with =1/=0."],"exampleFix":"// before\nexport ECC_DRY_RUN=true\n// after\nexport ECC_DRY_RUN=1","handlingStrategy":"validation","validationCode":"const v = process.env.ECC_DRY_RUN;\nif (v !== undefined && v !== '0' && v !== '1') {\n  throw new Error('ECC_DRY_RUN must be \"1\" or \"0\" when set');\n}","typeGuard":"function isValidDryRun(v) {\n  return v === undefined || v === '0' || v === '1';\n}","tryCatchPattern":"try {\n  runUninstall(argv);\n} catch (e) {\n  if (e.message.includes('ECC_DRY_RUN')) {\n    console.error('Fix ECC_DRY_RUN in your environment: use exactly 1 or 0, or unset it.');\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Use ECC_DRY_RUN=1 / ECC_DRY_RUN=0 only; never true/false/yes/no.","Grep .env, CI configs, and shell rc files for ECC_DRY_RUN when the error appears.","Prefer passing an explicit --dry-run style flag over env vars where supported."],"tags":["environment-variable","validation","dry-run"],"backgroundTag":"invalid-env-var-value","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"}