{"record":{"id":"e710d8128bb678cd","repo":"jackwener/OpenCLI","slug":"invalid-bookmark-type-type-expected-illust","errorCode":null,"errorMessage":"Invalid bookmark type: ${type}. Expected \"illust\" or \"novel\".","messagePattern":"Invalid bookmark type: (.+?)\\. Expected \"illust\" or \"novel\"\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/bookmark-utils.js","lineNumber":15,"sourceCode":"import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport {\n  getCurrentPixivUser,\n  normalizePixivNonNegativeInteger,\n  normalizePixivPositiveInteger,\n  pixivFetch,\n  requirePixivId,\n  requirePixivPayloadObject,\n  requirePixivString,\n} from './utils.js';\n\nexport function normalizeBookmarkType(value) {\n  const type = String(value ?? 'illust').trim();\n  if (type !== 'illust' && type !== 'novel') {\n    throw new ArgumentError(`Invalid bookmark type: ${type}. Expected \"illust\" or \"novel\".`);\n  }\n  return type;\n}\n\nexport function dateOnly(value) {\n  if (value == null || value === '') return '';\n  if (typeof value !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}(?:T|$)/.test(value)) {\n    throw new CommandExecutionError('Pixiv bookmark item returned malformed creation date');\n  }\n  return value.split('T')[0];\n}\n\nexport function tagsToString(tags) {\n  if (tags == null) return '';\n  const values = Array.isArray(tags) ? tags : (Array.isArray(tags?.tags) ? tags.tags : null);\n  if (!values) {\n    throw new CommandExecutionError('Pixiv item returned malformed tags payload');\n  }","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/bookmark-utils.js#L1-L33","documentation":"normalizeBookmarkType validates the bookmark work type argument for pixiv CLI bookmark commands. Anything other than the exact strings 'illust' or 'novel' (after String coercion and trimming) is rejected with an ArgumentError, since the Pixiv API only supports these two bookmark categories.","triggerScenarios":"Calling a bookmark command (e.g. bookmark list/download) with --type set to a misspelled or unsupported value such as 'artwork', 'image', 'Illust' (uppercase), 'novels', or any non-empty string that is not exactly 'illust' or 'novel'.","commonSituations":"Typos in CLI flags, users copying examples for other Pixiv wrappers that use 'artwork'/'novels', case sensitivity mistakes, passing a numeric or object value that coerces to an unexpected string.","solutions":["Set the type to exactly 'illust' or 'novel' (lowercase)","Remove surrounding whitespace or casing issues — the value is trimmed but is case-sensitive","Omit the value entirely: null/undefined defaults to 'illust'"],"exampleFix":"// before\nnormalizeBookmarkType('Artwork')\n// after\nnormalizeBookmarkType('illust')","handlingStrategy":"validation","validationCode":"function isValidBookmarkType(v) { const t = String(v ?? 'illust').trim(); return t === 'illust' || t === 'novel'; }\nif (!isValidBookmarkType(opts.type)) throw new Error(`--type must be \"illust\" or \"novel\", got: ${opts.type}`);","typeGuard":"function isBookmarkType(v) { return typeof v === 'string' && (v.trim() === 'illust' || v.trim() === 'novel'); }","tryCatchPattern":"try { const type = normalizeBookmarkType(input); /* ... */ } catch (err) { if (err instanceof ArgumentError) { console.error(`Bad --type: use \"illust\" or \"novel\"`); process.exitCode = 1; } else throw err; }","preventionTips":["Only pass the literal strings 'illust' or 'novel'","Rely on the default (omit the argument) when you want illust","Validate CLI flags with an enum/choices list (e.g. commander .choices(['illust','novel']))"],"tags":["cli","validation","argument-error","pixiv"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}