jackwener/OpenCLI · error

Collection not found: ${raw}. Available: ${(names.length ? n

Error message

Collection not found: ${raw}. Available: ${(names.length ? names.join(', ') : '(none)')}

What it means

Thrown when the target is treated as a name (non-numeric) and no collection in the account matches that exact name case-insensitively after trimming. The error helpfully lists available collection names so the caller can correct the target without a separate list call.

Source

Thrown at clis/instagram/collection-delete.js:58

  }
  const listData = await listRes.json();
  const collections = listData?.items || [];
  const isNumericId = /^\\d{6,}$/.test(raw);
  let id = '';
  let resolvedName = '';
  if (isNumericId) {
    const hit = collections.find((c) => String(c?.collection_id) === raw);
    if (!hit) {
      throw new Error('Collection id not found in your account: ' + raw);
    }
    id = String(hit.collection_id);
    resolvedName = String(hit.collection_name || '');
  } else {
    const wanted = raw.toLowerCase();
    const matches = collections.filter((c) => String(c?.collection_name || '').trim().toLowerCase() === wanted);
    if (matches.length === 0) {
      const names = collections.map((c) => c?.collection_name).filter(Boolean);
      throw new Error('Collection not found: ' + raw + '. Available: ' + (names.length ? names.join(', ') : '(none)'));
    }
    if (matches.length > 1) {
      const ids = matches.map((c) => c.collection_id).join(', ');
      throw new Error('Multiple collections share the name "' + raw + '" (ids: ' + ids + '). Pass the numeric collection_id explicitly to disambiguate.');
    }
    id = String(matches[0].collection_id);
    resolvedName = String(matches[0].collection_name || raw);
  }

  const fd = new FormData();
  fd.append('module_name', 'collection_settings');
  const res = await fetch('https://www.instagram.com/api/v1/collections/' + encodeURIComponent(id) + '/delete/', {
    method: 'POST',
    credentials: 'include',
    headers: { ...headers, 'X-CSRFToken': csrf },
    body: fd,
  });
  if (!res.ok) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use one of the names shown in the 'Available:' list, exactly
  2. Or pass the numeric collection_id instead of a name
  3. Re-list collections to see current names before retrying
  4. Fix typos or invisible characters in your configured target name

Example fix

// before
node collection-delete.js --target "MyCollction" // typo
// after
node collection-delete.js --target "My Collection" // exact available name
Defensive patterns

Strategy: validation

Validate before calling

const list = await listCollections();
const match = list.find((c) => c.collection_name.trim().toLowerCase() === targetName.toLowerCase());
if (!match) throw new Error('No such collection: ' + targetName + ' Available: ' + list.map((c) => c.collection_name).join(', '));

Type guard

function hasExactName(name: string, collections: {collection_name: string}[]): boolean {
  const w = name.trim().toLowerCase();
  return collections.some((c) => c.collection_name.trim().toLowerCase() === w);
}

Try / catch

try {
  await deleteCollection(name);
} catch (e) {
  if (String(e.message).startsWith('Collection not found')) {
    console.error(e.message); // lists available names
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Deleting by a name that doesn't exactly match — typos, extra punctuation, trailing whitespace differences beyond trim, renamed collections, or deleting a name that was already removed.

Common situations: Collections renamed in the UI since the script was written; case/character mismatches (emoji, accents); automation assuming a collection the user never created.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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