{"record":{"id":"f7768eed5f8f8dce","repo":"affaan-m/ECC","slug":"watch-needs-a-positive-seconds-value","errorCode":null,"errorMessage":"--watch needs a positive seconds value","messagePattern":"--watch needs a positive seconds value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/proximity-tick.js","lineNumber":31,"sourceCode":" * Messages are internal ECC agent-to-agent coordination (the ecc2 `messages`\n * table) — not any external channel.\n */\n\nconst { resolveControlPaneConfig, buildControlPaneSnapshot } = require('./lib/control-pane/state');\nconst { createProximityDispatcher, runProximityTick } = require('./lib/control-pane/proximity');\nconst { createEccMessageSink } = require('./lib/control-pane/message-sink');\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = { watchSec: 0, dryRun: false, json: false, help: false, dbPath: null, stateDbPath: null };\n  for (let i = 0; i < args.length; i += 1) {\n    const a = args[i];\n    if (a === '--help' || a === '-h') parsed.help = true;\n    else if (a === '--dry-run') parsed.dryRun = true;\n    else if (a === '--json') parsed.json = true;\n    else if (a === '--watch') {\n      const v = Number.parseInt(args[i + 1], 10);\n      if (!Number.isInteger(v) || v <= 0) throw new Error('--watch needs a positive seconds value');\n      parsed.watchSec = v;\n      i += 1;\n    } else if (a === '--db') {\n      parsed.dbPath = args[i + 1];\n      i += 1;\n    } else if (a === '--state-db') {\n      parsed.stateDbPath = args[i + 1];\n      i += 1;\n    } else {\n      throw new Error(`Unknown argument: ${a}`);\n    }\n  }\n  return parsed;\n}\n\nfunction showHelp() {\n  console.log(\n    [","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/proximity-tick.js#L13-L49","documentation":"parseArgs in scripts/proximity-tick.js handles the --watch flag by parsing the next argv token as an integer with Number.parseInt; it throws this error when the value is absent, non-numeric, or not a positive integer. This ensures the watch interval is a usable number of seconds before the loop starts.","triggerScenarios":"Running with `--watch` and no following value, a non-integer (`--watch 2.5`), a non-numeric token (`--watch abc`), zero or negative values (`--watch 0`, `--watch -1`), or another flag (`--watch --json`).","commonSituations":"Forgetting the seconds value at end of argv; interpolating an unset WATCH variable into a shell script; assuming fractional seconds are supported when only integers are.","solutions":["Pass a positive integer, e.g. `--watch 30`","Check shell variables for empty/invalid values before interpolation","Use whole seconds — fractional values are rejected","Ensure --watch is not the last token without a value"],"exampleFix":"// before\nnode scripts/proximity-tick.js --watch\n// after\nnode scripts/proximity-tick.js --watch 30","handlingStrategy":"validation","validationCode":"function validateWatchValue(raw) {\n  if (raw === undefined || raw.startsWith('--')) return false;\n  const n = Number.parseInt(raw, 10);\n  return Number.isInteger(n) && n > 0 && String(n) === raw;\n}","typeGuard":"function isPositiveInt(v) {\n  return Number.isInteger(v) && v > 0;\n}","tryCatchPattern":"try {\n  await main(process.argv);\n} catch (e) {\n  if (e.message.includes('--watch needs')) {\n    console.error(`${e.message}. Example: --watch 30`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always follow --watch with a whole positive number of seconds","Guard interpolated env values: \"${WATCH:?positive seconds required}\"","Use integers — fractional or negative values are rejected","Don't place --watch as the final argv token without a value"],"tags":["cli","argument-validation","watch-interval"],"backgroundTag":"invalid-flag-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"}