{"record":{"id":"d9fba9a4ca4493ab","repo":"chatboxai/chatbox","slug":"name-must-be-between-options-min-and-opt","errorCode":null,"errorMessage":"--${name} must be between ${options.min} and ${options.max}.","messagePattern":"--(.+?) must be between (.+?) and (.+?)\\.","errorType":"validation","errorClass":"ChatboxCliUsageError","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/chatbox-cli/parser.ts","lineNumber":120,"sourceCode":"}\n\nexport function booleanFlag(parsed: ParsedArguments, name: string): boolean {\n  return parsed.flags.get(name) === true\n}\n\nexport function integerFlag(\n  parsed: ParsedArguments,\n  name: string,\n  options: { defaultValue: number; min: number; max: number }\n): number {\n  const value = parsed.flags.get(name)\n  if (value === undefined) return options.defaultValue\n  if (typeof value !== 'string' || !/^\\d+$/.test(value)) {\n    throw new ChatboxCliUsageError(`--${name} must be an integer.`)\n  }\n  const result = Number(value)\n  if (result < options.min || result > options.max) {\n    throw new ChatboxCliUsageError(`--${name} must be between ${options.min} and ${options.max}.`)\n  }\n  return result\n}\n","sourceCodeStart":102,"sourceCodeEnd":124,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/chatbox-cli/parser.ts#L102-L124","documentation":"Thrown by integerFlag() after the value passes the integer regex but falls outside the [min, max] range declared in the flag's options. It enforces bounded numeric arguments so consumers never receive out-of-contract values. The bounds are set per flag at definition time, not configurable by the end user.","triggerScenarios":"Calling a CLI command whose integerFlag has {min,max} and passing a value below min or above max, e.g. a flag defined with {min:1,max:100} invoked as `--flag 0` or `--flag 500`. The check is `result < options.min || result > options.max`.","commonSituations":"User copies a value from another tool's defaults that exceeds this tool's cap; user misreads the limit as 0-indexed; environment/script supplies a large batch size or port number beyond the allowed band.","solutions":["Read the error message — it names the exact allowed range — and pass a value inside it.","Confirm the flag's defined min/max in its command definition if the message's range seems wrong.","If the legitimate use case needs a wider range, raise the {min,max} in the flag definition rather than bypassing the check."],"exampleFix":"// before (flag defined min:1, max:100)\nchatbox cmd --limit 500\n\n// after\nchatbox cmd --limit 100","handlingStrategy":"validation","validationCode":"function withinRange(n: number, min: number, max: number): boolean {\n  return Number.isInteger(n) && n >= min && n <= max\n}\nif (!withinRange(Number(raw), min, max)) { /* warn user, do not call */ }","typeGuard":"function isIntInRange(v: unknown, min: number, max: number): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= min && v <= max\n}","tryCatchPattern":"try {\n  const limit = integerFlag(parsed, 'limit', { defaultValue: 10, min: 1, max: 100 })\n} catch (e) {\n  if (e instanceof ChatboxCliUsageError && e.message.includes('must be between')) {\n    // prompt user for a value within range\n  }\n  throw e\n}","preventionTips":["Document the exact min/max for each integer flag in --help output.","Clamp user-supplied values to the range before invoking when a sensible default exists.","Surface the parsed range in the UI for GUI-wrapped CLI calls."],"tags":["cli","validation","user-input","parser"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}