jackwener/OpenCLI · error
Collection id not found in your account: ${raw}
Error message
Collection id not found in your account: ${raw} What it means
Thrown when the target looks like a numeric collection id (6+ digits) but no collection in the /collections/list/ response has that collection_id. The tool validates the id against the account's actual collections instead of letting the delete request fail with an opaque 404.
Source
Thrown at clis/instagram/collection-delete.js:49
// Resolve name -> id via /collections/list/. Always go through this path so we can
// surface an explicit error on duplicate names or unknown names instead of relying
// on a 404.
const listRes = await fetch('https://www.instagram.com/api/v1/collections/list/?collection_types=%5B%22MEDIA%22%5D', {
credentials: 'include',
headers,
});
if (!listRes.ok) {
throw new Error('Failed to list collections: HTTP ' + listRes.status + ' - make sure you are logged in to Instagram');
}
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);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- List your current collections and copy the correct numeric collection_id
- Confirm you are logged into the same account that owns the collection
- Check you didn't paste a media/post id instead of a collection id
- Remove stale ids from any cached config or scripts
Example fix
// before node collection-delete.js --target 17895600000000000 // stale id // after node collection-delete.js --target "My Collection" // resolve fresh by name
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the id by listing collections first
const list = await listCollections();
if (!list.some((c) => String(c.collection_id) === targetId)) {
throw new Error('Unknown collection id: ' + targetId);
} Type guard
function isKnownCollectionId(id: string, collections: {collection_id: string|number}[]): boolean {
return /^\d{6,}$/.test(id) && collections.some((c) => String(c.collection_id) === id);
} Try / catch
try {
await deleteCollection(rawId);
} catch (e) {
if (String(e.message).startsWith('Collection id not found')) {
const cols = await listCollections();
console.error('Valid ids:', cols.map((c) => c.collection_id).join(', '));
return;
}
throw e;
} Prevention
- Always fetch fresh collection ids rather than caching them
- Distinguish collection ids from media/post ids in your tooling
- Verify account identity matches the account owning the collection
- Delete by freshly listed id in scripts, not hand-copied ids
When it happens
Trigger: Passing a collection_id that was deleted already, belongs to a different account, was typo'd, or is not a collection id at all (e.g. a media id) while it matches the /^\d{6,}$/ heuristic.
Common situations: Stale id cached from a previous run; account switched mid-automation; confusing saved-collection ids with post/media ids; duplicates removed upstream.
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
- Collection not found: ${raw}. Available: ${(names.length ? n
- Multiple collections share the name "${raw}" (ids: ${ids}).
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- ${label} is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1bf9a8cdf43be378.
Report an issue: GitHub.