{"record":{"id":"2690cef131549199","repo":"jackwener/OpenCLI","slug":"sort-must-be-one-of-sort-options-join","errorCode":null,"errorMessage":"sort must be one of ${SORT_OPTIONS.join(', ')}","messagePattern":"sort must be one of (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/stackoverflow/tag.js","lineNumber":33,"sourceCode":"cli({\n    site: 'stackoverflow',\n    name: 'tag',\n    access: 'read',\n    description: 'List Stack Overflow questions tagged with a given tag (most active first).',\n    domain: 'stackoverflow.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'tag', positional: true, required: true, type: 'string', help: 'Tag slug (e.g. python, rust, typescript).' },\n        { name: 'sort', type: 'string', default: 'activity', help: `Sort key: ${SORT_OPTIONS.join(', ')}` },\n        { name: 'limit', type: 'int', default: 20, help: 'Max questions to return (max 100).' },\n    ],\n    columns: ['rank', 'id', 'title', 'score', 'answers', 'views', 'isAnswered', 'tags', 'author', 'createdAt', 'lastActivityAt', 'url'],\n    func: async (args) => {\n        const tag = requireString(args.tag, 'tag').toLowerCase();\n        const sort = String(args.sort ?? 'activity').toLowerCase();\n        if (!SORT_OPTIONS.includes(sort)) {\n            throw new ArgumentError(`sort must be one of ${SORT_OPTIONS.join(', ')}`);\n        }\n        const limit = normalizeLimit(args.limit, 20, 100, 'limit');\n        const data = await seFetch(`/questions`, {\n            searchParams: {\n                tagged: tag,\n                order: 'desc',\n                sort,\n                pagesize: limit,\n            },\n        });\n        const items = ensureItems(data, `stackoverflow tag \"${tag}\"`);\n        return items.slice(0, limit).map((q, i) => ({\n            rank: i + 1,\n            id: q.question_id,\n            title: decodeHtmlEntities(q.title || ''),\n            score: q.score ?? 0,\n            answers: q.answer_count ?? 0,\n            views: q.view_count ?? 0,","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/stackoverflow/tag.js#L15-L51","documentation":"ArgumentError from `stackoverflow tag` when the `sort` flag is not one of the accepted question-sort keys for the /questions endpoint (activity, votes, creation, hot, week, month per the command's SORT_OPTIONS). The value is lowercased before the membership check, so only unknown keys fail. This validation happens before any network request.","triggerScenarios":"`stackoverflow tag <tag> --sort relevance`, `--sort newest`, `--sort answered`, or any key not in the command's SORT_OPTIONS array.","commonSituations":"Using web-UI sort names ('Newest', 'Active') in flag form; carrying over sort values from other CLI commands with different option sets; typos like 'vote' or 'activty'.","solutions":["Use an accepted sort key (see `stackoverflow tag --help`; e.g. `--sort votes`).","Omit --sort entirely to use the default 'activity'.","Check the SORT_OPTIONS list at the top of clis/stackoverflow/tag.js if help text is unclear."],"exampleFix":"// before\nstackoverflow tag javascript --sort newest\n// after\nstackoverflow tag javascript --sort creation","handlingStrategy":"validation","validationCode":"const SORTS = ['activity', 'votes', 'creation'];\nconst s = String(sort).toLowerCase();\nif (!SORTS.includes(s)) throw new TypeError(`sort must be one of ${SORTS.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  await byTag(tag, { sort });\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message.startsWith('sort must be one of')) {\n    return byTag(tag, { sort: 'activity' }); // fall back to default\n  }\n  throw e;\n}","preventionTips":["Omit --sort to get the safe default ('activity').","Check --help for the accepted keys instead of copying values from other commands.","Map web-UI sort names ('Newest' → 'creation', 'Active' → 'activity') in wrappers."],"tags":["argument-validation","cli","invalid-option"],"backgroundTag":"invalid-option-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}