jackwener/OpenCLI · error · ArgumentError
${label} must be <= ${maxValue}
Error message
${label} must be <= ${maxValue} What it means
ArgumentError from normalizeLimit, the typed-fail-fast limit validator. After coercing to a positive integer via normalizePositiveInteger, it rejects values exceeding the caller-specified maxValue instead of silently clamping, per the library's no-silent-clamp convention.
Source
Thrown at clis/1point3acres/utils.js:22
* Site is a Discuz!X PHP BBS that serves GBK-encoded HTML.
* - Thread listings: /bbs/forum.php?mod=guide&view={hot|new|digest|newthread}
* - Forum: /bbs/forum-<fid>-<page>.html
* - Thread detail: /bbs/thread-<tid>-<page>-1.html
* - User profile: /bbs/space-uid-<uid>.html or /bbs/space-username-<name>.html
* - Search: /bbs/search.php?mod=forum (COOKIE — guests get an alert page)
*/
import { AuthRequiredError, ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
export const BASE = 'https://www.1point3acres.com/bbs';
/**
* Validate `limit` per typed-fail-fast convention (no silent clamp).
* Throws ArgumentError on non-positive / non-integer / out-of-range input.
*/
export function normalizeLimit(value, defaultValue, maxValue, label = 'limit') {
const limit = normalizePositiveInteger(value, defaultValue, label);
if (limit > maxValue) {
throw new ArgumentError(`${label} must be <= ${maxValue}`);
}
return limit;
}
/** Validate a positive integer argument without silently flooring/clamping. */
export function normalizePositiveInteger(value, defaultValue, label = 'value', { min = 1 } = {}) {
const raw = value ?? defaultValue;
const limit = Number(raw);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError(`${label} must be a positive integer`);
}
if (limit < min) {
throw new ArgumentError(`${label} must be >= ${min}`);
}
return limit;
}
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0 Safari/537.36';View on GitHub (pinned to 49907e53dc)
Solutions
- Lower limit to the command's documented maximum
- Read the error message: it states the exact max allowed (e.g. 'limit must be <= 50')
- If you truly need more results, paginate by increasing `page`/offset semantics rather than raising limit
- Clamp explicitly in your own code before calling if deliberate: limit = Math.min(limit, MAX)
- Note: no silent clamping — you must fix the value yourself
Example fix
// before
search({ query: 'h1b', limit: 500 }) // ArgumentError: limit must be <= 50
// after
const MAX = 50;
search({ query: 'h1b', limit: Math.min(500, MAX) }) Defensive patterns
Strategy: validation
Validate before calling
const MAX_LIMIT = 50; // per command docs
const safeLimit = (v) => {
const n = Number(v);
if (!Number.isInteger(n) || n <= 0) throw new Error('limit must be a positive integer');
return Math.min(n, MAX_LIMIT); // explicit clamp, your choice not the library's
}; Type guard
const isUsableLimit = (v, max) => Number.isInteger(v) && v > 0 && v <= max;
Try / catch
try {
await search({ query, limit });
} catch (e) {
if (e instanceof ArgumentError && /must be <=/.test(e.message)) {
const max = Number(e.message.match(/<= (\d+)/)?.[1]);
await search({ query, limit: max });
} else throw e;
} Prevention
- Clamp limit explicitly in your own code before calling
- Read each command's documented max — caps differ per command
- Parse CLI flags with parseInt so limits arrive as integers
- Remember the library never silently clamps — decide the clamp yourself
When it happens
Trigger: Calling a 1point3acres command (e.g. search) with limit above the command's max (e.g. limit: 100 when max is 50); misreading the default limit as a max; copying a limit from another command with a different ceiling.
Common situations: Pagination loops that compute limit dynamically and overshoot the max; users asking for 'all results' by passing a huge limit; config files shared between commands with different caps.
Related errors
- ${label} must be a positive integer
- ${label} must be >= ${min}
- --${name} must be between ${min} and ${max}, got ${parsed}
- INVALID_LIMIT
- juejin ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/919f2eadfbdd379f.
Report an issue: GitHub.