{"record":{"id":"ecd3ba69f0605913","repo":"jackwener/OpenCLI","slug":"failed-to-list-collections-http-listres-statu","errorCode":null,"errorMessage":"Failed to list collections: HTTP ' + listRes.status + ' - make sure you are logged in to Instagram","messagePattern":"Failed to list collections: HTTP ' \\+ listRes\\.status \\+ ' - make sure you are logged in to Instagram","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/instagram/saved.js","lineNumber":25,"sourceCode":"    domain: 'www.instagram.com',\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Number of saved posts' },\n        { name: 'collection', help: 'Collection name (case-insensitive). Omit for the default \"All posts\" feed.' },\n    ],\n    columns: ['index', 'user', 'caption', 'likes', 'comments', 'type'],\n    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 || '',","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/saved.js#L7-L43","documentation":"Thrown by the `saved` command when the collections list request (GET /api/v1/collections/list/) returns a non-2xx status. Because this Instagram web API requires an authenticated session, the message appends 'make sure you are logged in to Instagram'. It only fires when a --collection argument was supplied, since the collections list is fetched solely to resolve the collection name to an id.","triggerScenarios":"Running `instagram saved --collection <name>` while the browser session is expired or absent (401/403), while rate-limited (429), or when Instagram challenges the request (400) — any non-ok response from the collections/list endpoint.","commonSituations":"Session cookies expired since the last use; running the command from a fresh browser profile that was never logged in; heavy scripted usage triggering 429; corporate proxy stripping cookies causing a 401.","solutions":["Log into instagram.com in the browser profile the CLI drives, then re-run the command.","If 429, wait a few minutes and reduce how often you call the command.","If you don't actually need a specific collection, omit --collection to use the default saved-posts feed, which avoids the collections call entirely.","Verify cookies (sessionid/csrftoken) are present and not blocked by proxy/privacy settings."],"exampleFix":"// before (no session)\ninstagram saved --collection \"recipes\"  // -> Failed to list collections: HTTP 401...\n// after: log into instagram.com in the CLI browser profile, then\ninstagram saved --collection \"recipes\"","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await run(['instagram', 'saved', '--collection', name]);\n} catch (e) {\n  if (String(e.message).includes('Failed to list collections')) {\n    await refreshInstagramLogin();\n    // fall back to the default saved feed, which skips the collections call\n    return run(['instagram', 'saved']);\n  }\n  throw e;\n}","preventionTips":["Log into instagram.com in the CLI browser profile before using --collection.","Omit --collection when you only need the default saved feed.","Avoid high-frequency calls that trigger 429 rate limiting."],"tags":["network","authentication","http-error","instagram"],"backgroundTag":"http-401-unauthorized","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}