{"record":{"id":"0dc0f768dbf470f4","repo":"jackwener/OpenCLI","slug":"collection-not-found-collectionarg-avail","errorCode":null,"errorMessage":"Collection not found: ' + collectionArg + '. Available: ' + (names.length ? names.join(', ') : '(none)')","messagePattern":"Collection not found: ' \\+ collectionArg \\+ '\\. Available: ' \\+ \\(names\\.length \\? names\\.join\\(', '\\) : '\\(none\\)'\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/instagram/saved.js","lineNumber":31,"sourceCode":"    pipeline: [\n        { navigate: 'https://www.instagram.com' },\n        { evaluate: `(async () => {\n  const limit = \\${{ args.limit }};\n  const collectionArg = \\${{ args.collection | json }};\n  const headers = { 'X-IG-App-ID': '936619743392459' };\n  const opts = { credentials: 'include', headers };\n\n  let endpoint = 'https://www.instagram.com/api/v1/feed/saved/posts/';\n  if (collectionArg && String(collectionArg).trim()) {\n    const wanted = String(collectionArg).trim().toLowerCase();\n    const listRes = await fetch('https://www.instagram.com/api/v1/collections/list/?collection_types=%5B%22MEDIA%22%2C%22ALL_MEDIA_AUTO_COLLECTION%22%5D', opts);\n    if (!listRes.ok) throw new Error('Failed to list collections: HTTP ' + listRes.status + ' - make sure you are logged in to Instagram');\n    const listData = await listRes.json();\n    const collections = listData?.items || [];\n    const match = collections.find((c) => String(c?.collection_name || '').trim().toLowerCase() === wanted);\n    if (!match) {\n      const names = collections.map((c) => c?.collection_name).filter(Boolean);\n      throw new Error('Collection not found: ' + collectionArg + '. Available: ' + (names.length ? names.join(', ') : '(none)'));\n    }\n    endpoint = 'https://www.instagram.com/api/v1/feed/collection/' + encodeURIComponent(match.collection_id) + '/posts/';\n  }\n\n  const res = await fetch(endpoint, opts);\n  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');\n  const data = await res.json();\n  return (data?.items || []).slice(0, limit).map((item, i) => {\n    const m = item?.media;\n    return {\n      index: i + 1,\n      user: m?.user?.username || '',\n      caption: (m?.caption?.text || '').replace(/\\\\n/g, ' ').substring(0, 100),\n      likes: m?.like_count ?? 0,\n      comments: m?.comment_count ?? 0,\n      type: m?.media_type === 1 ? 'photo' : m?.media_type === 2 ? 'video' : 'carousel',\n    };\n  });","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/saved.js#L13-L49","documentation":"Thrown when the collections list succeeded but no collection's `collection_name` matches the requested --collection value (case-insensitive, trimmed). The error includes the list of available collection names, or '(none)' when the account has no named collections. Note the auto-collection 'All posts' is a special feed and may not appear as a named collection here.","triggerScenarios":"Running `instagram saved --collection <name>` where the name does not exactly (case-insensitively) match any collection_name returned by /api/v1/collections/list/ — typos, stale collection names after a rename/deletion, or requesting 'All posts' which is not a named collection.","commonSituations":"Typo or extra whitespace/emoji differences in the collection name; the collection was renamed or deleted on another device; expecting the default 'All posts' pseudo-collection to be listed; Instagram truncating the collections list response.","solutions":["Use one of the exact names printed in the error's 'Available:' list.","Omit --collection entirely to read the default saved-posts feed instead of a named collection.","Check the collection name in the Instagram app (Saved -> collection) — copy it exactly, matching is case-insensitive but otherwise literal.","If the collection should exist but the list is '(none)' or stale, re-login/reload instagram.com so the collections endpoint returns fresh data."],"exampleFix":"// before\ninstagram saved --collection \"Recepies\"\n// after (using the actual name)\ninstagram saved --collection \"Recipes\"","handlingStrategy":"validation","validationCode":"const available = await listCollectionNames(); // via /api/v1/collections/list/\nconst wanted = String(args.collection).trim().toLowerCase();\nif (!available.some(n => String(n).trim().toLowerCase() === wanted)) {\n  throw new Error(`Unknown collection '${args.collection}'. Available: ${available.join(', ') || '(none)'}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await run(['instagram', 'saved', '--collection', name]);\n} catch (e) {\n  if (String(e.message).includes('Collection not found')) {\n    // message lists available names — parse them and prompt/retry with a corrected name\n    const available = String(e.message).split('Available:')[1]?.trim() || '(none)';\n    console.error(`Pick a collection from: ${available}`);\n  }\n  throw e;\n}","preventionTips":["Copy collection names exactly from the Instagram app; matching is case-insensitive but literal otherwise.","Omit --collection for the default feed instead of guessing 'All posts'.","Re-check names after renaming/deleting collections on other devices."],"tags":["validation","argument-error","instagram"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}