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

  1. Pass exactly "show" (public bookmarks) or "hide" (private bookmarks), lowercase.
  2. Omit both kwargs.visibility and kwargs.rest to get the default "show".
  3. Normalize/validate input at your CLI boundary before calling, e.g. map public/private to show/hide.
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/bebb81d77c163bc1. Report an issue: GitHub.