{"record":{"id":"f1dd119887521ee0","repo":"affaan-m/ECC","slug":"exit-code-with-watch-requires-watch-count-so","errorCode":null,"errorMessage":"--exit-code with --watch requires --watch-count so the process can exit","messagePattern":"--exit-code with --watch requires --watch-count so the process can exit","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/loop-status.js","lineNumber":126,"sourceCode":"      options.exitCode = true;\n    } else if (arg === '--watch') {\n      options.watch = true;\n    } else if (arg === '--watch-count') {\n      options.watchCount = readPositiveInteger(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--watch-interval-seconds') {\n      options.watchIntervalSeconds = readPositiveNumber(readValue(args, index, arg), arg);\n      index += 1;\n    } else if (arg === '--write-dir') {\n      options.writeDir = readValue(args, index, arg);\n      index += 1;\n    } else {\n      throw new Error(`Unknown option: ${arg}`);\n    }\n  }\n\n  if (options.exitCode && options.watch && options.watchCount === null) {\n    throw new Error('--exit-code with --watch requires --watch-count so the process can exit');\n  }\n\n  return options;\n}\n\nfunction normalizeOptions(options = {}) {\n  return {\n    ...options,\n    bashTimeoutSeconds: options.bashTimeoutSeconds ?? DEFAULT_BASH_TIMEOUT_SECONDS,\n    exitCode: Boolean(options.exitCode),\n    limit: options.limit ?? DEFAULT_LIMIT,\n    transcriptPaths: options.transcriptPaths || [],\n    watch: Boolean(options.watch),\n    watchCount: options.watchCount ?? null,\n    wakeGraceMultiplier: options.wakeGraceMultiplier ?? DEFAULT_WAKE_GRACE_MULTIPLIER,\n    watchIntervalSeconds: options.watchIntervalSeconds ?? DEFAULT_WATCH_INTERVAL_SECONDS,\n    writeDir: options.writeDir || null,\n  };","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/loop-status.js#L108-L144","documentation":"scripts/loop-status.js has an explicit combination guard in parseArgs: using --exit-code together with --watch only makes sense if --watch-count is also given, otherwise a watched loop would never terminate and the process could never exit with the requested code. When --exit-code and --watch are set but --watch-count is null, the parser throws this error before doing any work.","triggerScenarios":"Running `node scripts/loop-status.js --watch --exit-code 1` without `--watch-count N`.","commonSituations":"CI jobs that want a non-zero exit on status failure but forget the iteration cap; combining flags copied from two different example commands.","solutions":["Add an explicit count: `node scripts/loop-status.js --watch --exit-code 1 --watch-count 10`.","If you do not need a bounded watch, drop --exit-code (or drop --watch) so the guard no longer applies.","In CI, compute the count from your retry policy and pass it explicitly.","Wrap the invocation in a script that validates the flag combination before launching."],"exampleFix":"// before\nnode scripts/loop-status.js --watch --exit-code 1\n// after\nnode scripts/loop-status.js --watch --exit-code 1 --watch-count 10","handlingStrategy":"validation","validationCode":"const has = (f) => args.includes(f);\nif (has('--exit-code') && has('--watch') && !has('--watch-count')) {\n  throw new Error('--exit-code with --watch requires --watch-count');\n}","typeGuard":null,"tryCatchPattern":"try { run(args); } catch (e) { if (e.message.includes('--watch-count')) { console.error('Add --watch-count N when combining --watch and --exit-code'); process.exitCode = 2; } else throw e; }","preventionTips":["Define flag-combination rules once in wrapper scripts","Always pair --watch with --watch-count in CI templates","Add smoke tests for your standard invocations"],"tags":["cli","conflicting-flags","argument-parsing"],"backgroundTag":"conflicting-config-options","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"}