{"record":{"id":"bebb81d77c163bc1","repo":"jackwener/OpenCLI","slug":"invalid-bookmark-visibility-visibility-expect","errorCode":null,"errorMessage":"Invalid bookmark visibility: ${visibility}. Expected \"show\" or \"hide\".","messagePattern":"Invalid bookmark visibility: (.+?)\\. Expected \"show\" or \"hide\"\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/pixiv/bookmark-utils.js","lineNumber":89,"sourceCode":"    user_id: userId,\n    illust_id: isNovel ? '' : id,\n    novel_id: isNovel ? id : '',\n    pages: isNovel ? '' : optionalCount(item.pageCount ?? item.page_count, 'page count', 1),\n    words: isNovel ? optionalCount(item.wordCount ?? item.textCount ?? item.characterCount, 'word count') : '',\n    bookmarks: optionalCount(item.bookmarkCount ?? item.totalBookmarks, 'bookmark count', 0),\n    tags: tagsToString(item.tags),\n    created: dateOnly(item.createDate ?? item.created_at),\n    url: isNovel ? `https://www.pixiv.net/novel/show.php?id=${id}` : `https://www.pixiv.net/artworks/${id}`,\n  };\n}\n\nexport async function fetchCurrentBookmarks(page, kwargs = {}) {\n  const type = normalizeBookmarkType(kwargs.type);\n  const limit = normalizePixivPositiveInteger(kwargs.limit, 20, 'limit', { max: 100 });\n  const offset = normalizePixivNonNegativeInteger(kwargs.offset, 0, 'offset');\n  const visibility = String(kwargs.visibility ?? kwargs.rest ?? 'show');\n  if (visibility !== 'show' && visibility !== 'hide') {\n    throw new ArgumentError(`Invalid bookmark visibility: ${visibility}. Expected \"show\" or \"hide\".`);\n  }\n  const user = await getCurrentPixivUser(page);\n  const path = type === 'novel'\n    ? `/ajax/user/${user.id}/novels/bookmarks`\n    : `/ajax/user/${user.id}/illusts/bookmarks`;\n  const body = await pixivFetch(page, path, {\n    params: { tag: '', offset, limit, rest: visibility },\n  });\n  return normalizeBookmarkWorks(body).slice(0, limit).map((work, i) => bookmarkRow(work, offset + i, type, user.id));\n}\n","sourceCodeStart":71,"sourceCodeEnd":100,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/bookmark-utils.js#L71-L100","documentation":"fetchCurrentBookmarks accepts a visibility option (or the positional `rest` argument) that must be exactly the string \"show\" or \"hide\" — these map to Pixiv's public/private bookmark filters. Any other value (typos, \"public\", \"private\", numbers, undefined coerced oddly via String()) is rejected with this ArgumentError before any network call is made.","triggerScenarios":"Calling fetchCurrentBookmarks(page, { visibility: 'private' }) or { visibility: 'Public' } (case-sensitive check), passing rest: 'all', or passing a non-string kwarg that stringifies to something other than show/hide.","commonSituations":"Developer guesses the accepted values (uses Pixiv's own terms \"public\"/\"private\" instead of \"show\"/\"hide\"); casing mismatch like \"Show\"; passing rest as the second positional CLI argument with an unexpected word.","solutions":["Pass exactly \"show\" (public bookmarks) or \"hide\" (private bookmarks), lowercase.","Omit both kwargs.visibility and kwargs.rest to get the default \"show\".","Normalize/validate input at your CLI boundary before calling, e.g. map public/private to show/hide.","If a custom keyword was intended, check the library docs/source for supported values rather than Pixiv's web UI labels."],"exampleFix":"// before\nawait fetchCurrentBookmarks(page, { visibility: 'private' });\n// after\nawait fetchCurrentBookmarks(page, { visibility: 'hide' }); // 'hide' = private bookmarks, 'show' = public","handlingStrategy":"validation","validationCode":"const VISIBILITY = new Set(['show', 'hide']);\nfunction assertBookmarkVisibility(v) {\n  if (v !== undefined && !VISIBILITY.has(String(v))) {\n    throw new Error(`visibility must be \"show\" or \"hide\", got: ${v}`);\n  }\n}\nassertBookmarkVisibility(kwargs.visibility);","typeGuard":"function isBookmarkVisibility(v) {\n  return v === 'show' || v === 'hide';\n}","tryCatchPattern":"try {\n  const rows = await fetchCurrentBookmarks(page, { visibility });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.startsWith('Invalid bookmark visibility')) {\n    console.error(`Bad --visibility value; use \"show\" (public) or \"hide\" (private).`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Only ever pass the literal strings \"show\" or \"hide\"; remember they mean public/private, not Pixiv's web labels.","Use a constant/enum in your code instead of raw strings.","Validate CLI flags at the argument-parsing layer before reaching the library.","Prefer omitting the option (defaults to \"show\") when unsure."],"tags":["pixiv","argument-validation","cli-input"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}