jackwener/OpenCLI · error · ArgumentError
--page must be a positive integer (got ${raw})
Error message
--page must be a positive integer (got ${raw}) What it means
ArgumentError thrown by parsePageArg when --page is provided but is not an integer >= 1. Like parseLimitArg, it fails fast with the offending value rather than clamping to page 1.
Source
Thrown at clis/coupang/utils.js:29
*/
export function parseLimitArg(raw, fallback, max) {
if (raw === undefined || raw === null || raw === '') {
return fallback;
}
const num = Number(raw);
if (!Number.isInteger(num) || num < 1 || num > max) {
throw new ArgumentError(`--limit must be an integer between 1 and ${max} (got ${raw})`);
}
return num;
}
export function parsePageArg(raw, fallback) {
if (raw === undefined || raw === null || raw === '') {
return fallback;
}
const num = Number(raw);
if (!Number.isInteger(num) || num < 1) {
throw new ArgumentError(`--page must be a positive integer (got ${raw})`);
}
return num;
}
function itemKey(item) {
return item.url || item.product_id || `${item.title}:${item.price ?? ''}`;
}
const ROCKET_PATTERNS = ['판매자로켓', '로켓프레시', '로켓와우', '로켓배송', '로켓직구'];
const DELIVERY_TYPE_PATTERNS = ['무료배송', '일반배송'];
const DELIVERY_PROMISE_PATTERNS = ['오늘도착', '내일도착', '새벽도착', '오늘출발'];
const BADGE_ID_TO_ROCKET = {
ROCKET: '로켓배송',
ROCKET_MERCHANT: '판매자로켓',
ROCKET_WOW: '로켓와우',
WOW: '로켓와우',
ROCKET_FRESH: '로켓프레시',
FRESH: '로켓프레시',
SELLER_ROCKET: '판매자로켓',View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a positive integer (1-based)
- Omit --page to use the fallback (page 1)
- Fix the loop/index arithmetic producing 0 or negative pages
- Validate page values before invoking (Number.isInteger(p) && p >= 1)
Example fix
// before --page 0 // after --page 1
Defensive patterns
Strategy: validation
Validate before calling
function validPage(raw) { const n = Number(raw); return Number.isInteger(n) && n >= 1 ? n : 1; } Type guard
function isValidPage(v) { return typeof v === 'number' && Number.isInteger(v) && v >= 1; } Try / catch
try { await cli.run(['coupang','search', q, '--page', String(page)]); } catch (e) { if (e instanceof ArgumentError && e.message.startsWith('--page')) { page = 1; return retry(); } throw e; } Prevention
- Remember pages are 1-based; start loops at 1
- Compute page as index + 1, never index
- Sanitize numeric env vars before passing them as --page
When it happens
Trigger: Passing --page as 0, a negative number, a float (2.5), or a non-numeric string while running a paginated coupang search.
Common situations: Off-by-one pagination loops starting at 0; computing page from `index` instead of `index + 1`; environment variable interpolation producing 'NaN' or empty garbage.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- --offset must be a multiple of 10 for DuckDuckGo HTML pagina
- juejin ${label} must be <= ${maxValue}
- openreview ${label} must be a positive integer
- openreview ${label} must be <= ${maxValue}
- openreview ${label} must be a non-negative integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/af284c222cda0e2b.
Report an issue: GitHub.