{"record":{"id":"10017ac4a86c439c","repo":"jackwener/OpenCLI","slug":"unknown-sort-sort-valid-sorts-join","errorCode":null,"errorMessage":"Unknown sort \"${sort}\". Valid: ${SORTS.join(', ')}","messagePattern":"Unknown sort \"(.+?)\"\\. Valid: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/user-boards.js","lineNumber":28,"sourceCode":"cli({\n  site: 'pinterest',\n  name: 'user-boards',\n  access: 'read',\n  description: 'List a user\\'s boards',\n  domain: 'www.pinterest.com',\n  strategy: Strategy.COOKIE,\n  args: [\n    { name: 'username', type: 'string', positional: true, required: true, help: 'Username or profile URL, e.g. janedoe' },\n    { name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of boards (max ${MAX_LIMIT})` },\n    { name: 'sort', type: 'string', default: 'last_pinned_to', choices: SORTS, help: 'Board sort order' },\n  ],\n  columns: ['boardId', 'name', 'pinCount', 'sectionCount', 'privacy', 'url'],\n  func: async (page, kwargs) => {\n    const username = parseUsername(kwargs.username);\n    const limit = requireLimit(kwargs.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });\n    const sort = String(kwargs.sort ?? 'last_pinned_to');\n    if (!SORTS.includes(sort)) {\n      throw new ArgumentError(`Unknown sort \"${sort}\". Valid: ${SORTS.join(', ')}`);\n    }\n\n    const sourceUrl = `/${username}/`;\n    await page.goto(`${PINTEREST_BASE}${sourceUrl}`);\n\n    const rows = await collectResults(page, {\n      resource: 'BoardsResource',\n      baseOptions: { username, sort, privacy_filter: 'all', field_set_key: 'profile_grid_item' },\n      sourceUrl,\n      limit,\n      keyField: 'boardId',\n      pageSize: DEFAULT_PAGE_SIZE,\n      mapItem: (board) => {\n        if (!board || !board.id) return null;\n        return {\n          boardId: String(board.id),\n          name: board.name || '',\n          pinCount: typeof board.pin_count === 'number' ? board.pin_count : 0,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/user-boards.js#L10-L46","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"// before\npinterest user-boards someuser --sort newest   // not in SORTS\n// after\npinterest user-boards someuser --sort last_pinned_to","handlingStrategy":"validation","validationCode":"const SORTS = ['last_pinned_to']; // check --help for the authoritative list\nconst sort = argv.sort ?? 'last_pinned_to';\nif (!SORTS.includes(sort)) throw new Error(`Unknown sort \"${sort}\". Valid: ${SORTS.join(', ')}`);","typeGuard":"const isValidSort = (v) => typeof v === 'string' && SORTS.includes(v);","tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","argument-validation","invalid-enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}