jackwener/OpenCLI · error · ArgumentError
Unknown sort "${sort}". Valid: ${SORTS.join(', ')}
Error message
Unknown sort "${sort}". Valid: ${SORTS.join(', ')} What it means
The pinterest user-boards command validates the optional --sort value against a fixed allowlist (SORTS, default 'last_pinned_to'). Any value outside that list raises ArgumentError listing the valid options, preventing an invalid sort parameter from being sent to Pinterest.
Source
Thrown at clis/pinterest/user-boards.js:28
cli({
site: 'pinterest',
name: 'user-boards',
access: 'read',
description: 'List a user\'s boards',
domain: 'www.pinterest.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'username', type: 'string', positional: true, required: true, help: 'Username or profile URL, e.g. janedoe' },
{ name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of boards (max ${MAX_LIMIT})` },
{ name: 'sort', type: 'string', default: 'last_pinned_to', choices: SORTS, help: 'Board sort order' },
],
columns: ['boardId', 'name', 'pinCount', 'sectionCount', 'privacy', 'url'],
func: async (page, kwargs) => {
const username = parseUsername(kwargs.username);
const limit = requireLimit(kwargs.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });
const sort = String(kwargs.sort ?? 'last_pinned_to');
if (!SORTS.includes(sort)) {
throw new ArgumentError(`Unknown sort "${sort}". Valid: ${SORTS.join(', ')}`);
}
const sourceUrl = `/${username}/`;
await page.goto(`${PINTEREST_BASE}${sourceUrl}`);
const rows = await collectResults(page, {
resource: 'BoardsResource',
baseOptions: { username, sort, privacy_filter: 'all', field_set_key: 'profile_grid_item' },
sourceUrl,
limit,
keyField: 'boardId',
pageSize: DEFAULT_PAGE_SIZE,
mapItem: (board) => {
if (!board || !board.id) return null;
return {
boardId: String(board.id),
name: board.name || '',
pinCount: typeof board.pin_count === 'number' ? board.pin_count : 0,View on GitHub (pinned to 49907e53dc)
Solutions
- Use one of the listed valid values from the error message (run the command with --help to see SORTS)
- Fix typos against the canonical key 'last_pinned_to' (the default) or whatever values the error lists
- Drop the --sort flag entirely to accept the default ordering
Example fix
// before pinterest user-boards someuser --sort newest // not in SORTS // after pinterest user-boards someuser --sort last_pinned_to
Defensive patterns
Strategy: validation
Validate before calling
const SORTS = ['last_pinned_to']; // check --help for the authoritative list
const sort = argv.sort ?? 'last_pinned_to';
if (!SORTS.includes(sort)) throw new Error(`Unknown sort "${sort}". Valid: ${SORTS.join(', ')}`); Type guard
const isValidSort = (v) => typeof v === 'string' && SORTS.includes(v);
Prevention
- Copy sort values from --help output, never from memory
- Do not assume sort enums match other Pinterest APIs
- Omit --sort when unsure — the default (last_pinned_to) is always valid
When it happens
Trigger: Passing --sort (or kwargs.sort) with a value not in SORTS — e.g. 'name', 'newest', 'pinned', or a typo like 'last_pinned' instead of 'last_pinned_to'.
Common situations: Guessing sort keys instead of reading the command help, copying sort names from other Pinterest APIs or CLIs with different enums, or older scripts using a sort value that was renamed/removed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/10017ac4a86c439c.
Report an issue: GitHub.