{"record":{"id":"fb6df1198e706050","repo":"jackwener/OpenCLI","slug":"interval-must-be-an-integer-between-1-and-300-se","errorCode":null,"errorMessage":"--interval must be an integer between 1 and 300 seconds","messagePattern":"--interval must be an integer between 1 and 300 seconds","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trae-cn/utils.js","lineNumber":64,"sourceCode":"  const maxChars = value === undefined || value === null ? fallback : Number(value);\n  if (!Number.isInteger(maxChars) || maxChars < 0 || maxChars > 1_000_000) {\n    throw new ArgumentError('--max-chars must be an integer between 0 and 1000000');\n  }\n  return maxChars;\n}\n\nexport function normalizeDuration(value, fallback = 30) {\n  const duration = value === undefined || value === null ? fallback : Number(value);\n  if (!Number.isInteger(duration) || duration < 1 || duration > 3600) {\n    throw new ArgumentError('--duration must be an integer between 1 and 3600 seconds');\n  }\n  return duration;\n}\n\nexport function normalizeInterval(value, fallback = 2) {\n  const interval = value === undefined || value === null ? fallback : Number(value);\n  if (!Number.isInteger(interval) || interval < 1 || interval > 300) {\n    throw new ArgumentError('--interval must be an integer between 1 and 300 seconds');\n  }\n  return interval;\n}\n\nexport function normalizeApprovalKinds(value, fallback = TRAE_CN_APPROVAL_DEFAULT_KINDS.join(',')) {\n  const raw = value === undefined || value === null || value === '' ? fallback : value;\n  const parts = Array.isArray(raw) ? raw : String(raw).split(',');\n  const expanded = [];\n  for (const part of parts) {\n    const item = String(part || '').trim().toLowerCase();\n    if (!item) continue;\n    if (item === 'all') {\n      expanded.push('terminal', 'delete', 'keep');\n      continue;\n    }\n    if (!['terminal', 'delete', 'keep'].includes(item)) {\n      throw new ArgumentError('--approve-kinds must contain only terminal, delete, keep, or all');\n    }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-cn/utils.js#L46-L82","documentation":"normalizeInterval in utils.js throws an ArgumentError when the --interval value is not an integer between 1 and 300 seconds. The interval is the polling frequency between activity checks during watch/stream; it must be at least 1s and at most 5 minutes.","triggerScenarios":"Running watch commands with `--interval 0` (trying to poll as fast as possible), `--interval 301`, `--interval 0.5`, or non-numeric values.","commonSituations":"Expecting sub-second polling with --interval 0 or 0.2; passing milliseconds (--interval 500); empty shell variables collapsing to 0.","solutions":["Pass an integer between 1 and 300, e.g. --interval 2.","Omit --interval to use the 2-second default.","Accept the 1-second minimum for fastest polling: --interval 1.","Fix scripts interpolating empty variables: --interval \"${INTERVAL:-2}\"."],"exampleFix":"// before\nopencli trae-cn watch --interval 0\n// after\nopencli trae-cn watch --interval 1","handlingStrategy":"validation","validationCode":"function assertInterval(v, fallback = 2) {\n  const n = v === undefined || v === null ? fallback : Number(v);\n  if (!Number.isInteger(n) || n < 1 || n > 300) throw new Error(`Invalid --interval: ${JSON.stringify(v)}; must be an integer 1-300 seconds`);\n  return n;\n}","typeGuard":"function isValidInterval(v) {\n  return v === undefined || v === null ||\n    (Number.isInteger(Number(v)) && Number(v) >= 1 && Number(v) <= 300);\n}","tryCatchPattern":"try {\n  return await watchStream(interval);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--interval')) {\n    return watchStream(Math.min(Math.max(Number(interval) || 2, 1), 300));\n  }\n  throw e;\n}","preventionTips":["Sub-second polling is not supported; minimum is 1 second.","Pass seconds, not milliseconds (500ms is invalid).","Use ${INTERVAL:-2} in scripts to guard empty env vars.","Omit --interval to accept the 2s default."],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}