{"record":{"id":"0b705acb514753fb","repo":"jackwener/OpenCLI","slug":"max-chars-must-be-an-integer-between-0-and-10000","errorCode":null,"errorMessage":"--max-chars must be an integer between 0 and 1000000","messagePattern":"--max-chars must be an integer between 0 and 1000000","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trae-cn/utils.js","lineNumber":48,"sourceCode":"  const timeout = value === undefined || value === null ? fallback : Number(value);\n  if (!Number.isInteger(timeout) || timeout < 1) {\n    throw new ArgumentError('--timeout must be a positive integer (seconds)');\n  }\n  return timeout;\n}\n\nexport function normalizeLimit(value, fallback = 20) {\n  const limit = value === undefined || value === null ? fallback : Number(value);\n  if (!Number.isInteger(limit) || limit < 1 || limit > 200) {\n    throw new ArgumentError('--limit must be an integer between 1 and 200');\n  }\n  return limit;\n}\n\nexport function normalizeMaxChars(value, fallback = 6000) {\n  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;","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-cn/utils.js#L30-L66","documentation":"normalizeMaxChars in utils.js throws an ArgumentError when the --max-chars value is not an integer in the range 0-1000000. This option truncates captured activity text; 0 is allowed (captures nothing) but negatives, floats, and non-numbers are rejected.","triggerScenarios":"Running a command with `--max-chars -1`, `--max-chars 1000001`, `--max-chars 5.5`, or non-numeric strings like `--max-chars unlimited`.","commonSituations":"Trying to remove the cap by passing a huge number beyond 1,000,000; empty shell variables (Number('') === 0 is valid here, but ' ' trims to '' -> 0); unit-suffixed values like `--max-chars 10k`.","solutions":["Pass an integer between 0 and 1000000, e.g. --max-chars 6000.","Omit --max-chars to use the 6000 default.","Use --max-chars 1000000 (the maximum) rather than a larger value.","Fix scripts so unset variables don't produce invalid numbers."],"exampleFix":"// before\nopencli trae-cn activity --max-chars 99999999\n// after\nopencli trae-cn activity --max-chars 1000000","handlingStrategy":"validation","validationCode":"function assertMaxChars(v, fallback = 6000) {\n  const n = v === undefined || v === null ? fallback : Number(v);\n  if (!Number.isInteger(n) || n < 0 || n > 1_000_000) throw new Error(`Invalid --max-chars: ${JSON.stringify(v)}; must be an integer 0-1000000`);\n  return n;\n}","typeGuard":"function isValidMaxChars(v) {\n  return v === undefined || v === null ||\n    (Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= 1_000_000);\n}","tryCatchPattern":"try {\n  return await listActivities(maxChars);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--max-chars')) {\n    return listActivities(Math.min(Math.max(Number(maxChars) || 6000, 0), 1_000_000));\n  }\n  throw e;\n}","preventionTips":["Cap values at 1000000 instead of inventing larger 'unlimited' numbers.","Remember 0 is valid (truncate everything) but negatives are not.","Avoid unit suffixes like 10k — pass the expanded integer.","Omit the flag to accept the 6000 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"}