{"record":{"id":"9c39f9d3ad788c50","repo":"jackwener/OpenCLI","slug":"juejin-category-value-is-not-recognised","errorCode":null,"errorMessage":"juejin category \"${value}\" is not recognised","messagePattern":"juejin category \"(.+?)\" is not recognised","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/juejin/utils.js","lineNumber":75,"sourceCode":"    if (typeof raw === 'number') {\n        if (Number.isSafeInteger(raw) && raw >= 0) return String(raw);\n        throw new ArgumentError('juejin cursor must be a non-negative decimal integer');\n    }\n    if (typeof raw === 'string' && /^(0|[1-9]\\d*)$/.test(raw)) {\n        return raw;\n    }\n    throw new ArgumentError('juejin cursor must be a non-negative decimal integer');\n}\n\n/** Resolve a `--category` arg to the underlying numeric category id. */\nexport function resolveCategory(value) {\n    if (value == null) return '';\n    const raw = String(value).trim();\n    if (!raw) return '';\n    if (JUEJIN_ID.test(raw)) return raw;\n    const slug = raw.toLowerCase();\n    if (CATEGORY_ALIASES[slug]) return CATEGORY_ALIASES[slug];\n    throw new ArgumentError(\n        `juejin category \"${value}\" is not recognised`,\n        `Use a category id (e.g. \"${CATEGORY_ALIASES.backend}\") or one of: ${Object.keys(CATEGORY_ALIASES).join(', ')}.`,\n    );\n}\n\n/**\n * POST JSON to a Juejin endpoint. The API returns `{ err_no, err_msg, data }`;\n * a non-zero `err_no` is surfaced as a typed `CommandExecutionError`.\n */\nexport async function juejinFetch(path, body, label, method = 'POST') {\n    const url = `${JUEJIN_API_BASE}${path}`;\n    let resp;\n    try {\n        const init = {\n            method,\n            headers: { 'user-agent': UA, accept: 'application/json' },\n        };\n        if (method === 'POST') {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/juejin/utils.js#L57-L93","documentation":"resolveCategory maps a user-supplied --category value (numeric category id or human-friendly slug like 'backend') to Juejin's internal category id. If the trimmed value is neither a valid Juejin id nor a known alias key, an ArgumentError is thrown with a hint listing accepted slugs and an example id.","triggerScenarios":"Passing an unknown --category value such as --category frontend2, --category \"Front End\", --category \"ai-ml\", a misspelled slug, or an id from a different Juejin entity (e.g. a tag id or user id).","commonSituations":"Guessing slug names instead of checking --help (aliases are snake_case like 'backend', 'frontend', 'android', 'ios', 'ai', 'codepig' etc. per CATEGORY_ALIASES); using an article/tag id rather than a category id; renaming drift after the alias table changed between CLI versions.","solutions":["Use one of the listed alias slugs, e.g. --category backend (the error hint enumerates all valid keys).","Use a valid numeric category id (the JUEJIN_ID format) copied from a Juejin category URL.","Run the CLI's help to see the accepted category names for your installed version.","Update the CLI if a new Juejin category was added after your version's alias table was written; otherwise contribute the alias to CATEGORY_ALIASES."],"exampleFix":"// before\ncli({ category: 'front-end' }); // not an alias\n// after\ncli({ category: 'frontend' }); // valid alias in CATEGORY_ALIASES\n// or\ncli({ category: '6809637773935378440' }); // raw id","handlingStrategy":"validation","validationCode":"const VALID = new Set(['backend','frontend','android','ios','ai','devops','codepig']); // mirror CATEGORY_ALIASES\nfunction resolveCat(v){ if (v == null) return ''; const s = String(v).trim(); if (!s) return ''; if (/^\\d+$/.test(s)) return s; if (VALID.has(s.toLowerCase())) return s; throw new Error(`unknown category \"${v}\"; use one of: ${[...VALID].join(', ')}`); }","typeGuard":"function isKnownCategory(v){ if (v == null) return true; const s = String(v).trim().toLowerCase(); return /^\\d+$/.test(s) || VALID.has(s); }","tryCatchPattern":"try {\n  cli({ category });\n} catch (e) {\n  if (/is not recognised/.test(e.message)) {\n    console.error(e.message); // hint lists accepted slugs\n    cli({ category: 'backend' });\n  } else throw e;\n}","preventionTips":["Enumerate slugs from --help or the error hint instead of guessing names.","Copy the numeric category id from the Juejin category page URL if unsure.","Validate user input against the alias list before composing the command.","Keep your wrapper's alias table in sync with the CLI version you deploy."],"tags":["argument-validation","cli","enum","input-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}