jackwener/OpenCLI · warning · ArgumentError
Invalid bookmark visibility: ${visibility}. Expected "show"
Error message
Invalid bookmark visibility: ${visibility}. Expected "show" or "hide". What it means
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.
Source
Thrown at clis/pixiv/bookmark-utils.js:89
user_id: userId,
illust_id: isNovel ? '' : id,
novel_id: isNovel ? id : '',
pages: isNovel ? '' : optionalCount(item.pageCount ?? item.page_count, 'page count', 1),
words: isNovel ? optionalCount(item.wordCount ?? item.textCount ?? item.characterCount, 'word count') : '',
bookmarks: optionalCount(item.bookmarkCount ?? item.totalBookmarks, 'bookmark count', 0),
tags: tagsToString(item.tags),
created: dateOnly(item.createDate ?? item.created_at),
url: isNovel ? `https://www.pixiv.net/novel/show.php?id=${id}` : `https://www.pixiv.net/artworks/${id}`,
};
}
export async function fetchCurrentBookmarks(page, kwargs = {}) {
const type = normalizeBookmarkType(kwargs.type);
const limit = normalizePixivPositiveInteger(kwargs.limit, 20, 'limit', { max: 100 });
const offset = normalizePixivNonNegativeInteger(kwargs.offset, 0, 'offset');
const visibility = String(kwargs.visibility ?? kwargs.rest ?? 'show');
if (visibility !== 'show' && visibility !== 'hide') {
throw new ArgumentError(`Invalid bookmark visibility: ${visibility}. Expected "show" or "hide".`);
}
const user = await getCurrentPixivUser(page);
const path = type === 'novel'
? `/ajax/user/${user.id}/novels/bookmarks`
: `/ajax/user/${user.id}/illusts/bookmarks`;
const body = await pixivFetch(page, path, {
params: { tag: '', offset, limit, rest: visibility },
});
return normalizeBookmarkWorks(body).slice(0, limit).map((work, i) => bookmarkRow(work, offset + i, type, user.id));
}
View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
await fetchCurrentBookmarks(page, { visibility: 'private' });
// after
await fetchCurrentBookmarks(page, { visibility: 'hide' }); // 'hide' = private bookmarks, 'show' = public Defensive patterns
Strategy: validation
Validate before calling
const VISIBILITY = new Set(['show', 'hide']);
function assertBookmarkVisibility(v) {
if (v !== undefined && !VISIBILITY.has(String(v))) {
throw new Error(`visibility must be "show" or "hide", got: ${v}`);
}
}
assertBookmarkVisibility(kwargs.visibility); Type guard
function isBookmarkVisibility(v) {
return v === 'show' || v === 'hide';
} Try / catch
try {
const rows = await fetchCurrentBookmarks(page, { visibility });
} catch (e) {
if (e instanceof ArgumentError && e.message.startsWith('Invalid bookmark visibility')) {
console.error(`Bad --visibility value; use "show" (public) or "hide" (private).`);
process.exitCode = 2;
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid illustration ID: ${id}
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
- archive snapshots limit must be <= 1000
- archive snapshots ${key} must be a digit-only timestamp (YYY
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bebb81d77c163bc1.
Report an issue: GitHub.