{"record":{"id":"3083678a7d0e7624","repo":"jackwener/OpenCLI","slug":"unsupported-instagram-media-url-raw","errorCode":null,"errorMessage":"Unsupported Instagram media URL: ${raw}","messagePattern":"Unsupported Instagram media URL: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/download.js","lineNumber":74,"sourceCode":"        throw new ArgumentError(`Unsupported URL protocol: ${url.protocol}`);\n    }\n    const host = url.hostname.toLowerCase();\n    if (host !== INSTAGRAM_HOST_SUFFIX && !host.endsWith(`.${INSTAGRAM_HOST_SUFFIX}`)) {\n        throw new ArgumentError(`Unsupported host: ${host}`, 'Only instagram.com URLs are supported');\n    }\n    const segments = url.pathname.split('/').filter(Boolean);\n    let kind;\n    let shortcode;\n    if (segments.length >= 2 && SUPPORTED_KINDS.has(segments[0])) {\n        kind = segments[0];\n        shortcode = segments[1];\n    }\n    else if (segments.length >= 3 && SUPPORTED_KINDS.has(segments[1])) {\n        kind = segments[1];\n        shortcode = segments[2];\n    }\n    if (!kind || !shortcode) {\n        throw new ArgumentError(`Unsupported Instagram media URL: ${raw}`, 'Only /p/<shortcode>/, /reel/<shortcode>/, and /tv/<shortcode>/ links are supported');\n    }\n    if (!shortcodeToMediaId(shortcode)) {\n        throw new ArgumentError(`Invalid Instagram shortcode: ${shortcode}`, 'Copy the link straight from the post, without escaping it');\n    }\n    return {\n        kind: kind,\n        shortcode,\n        canonicalUrl: `https://www.instagram.com/${kind}/${shortcode}/`,\n    };\n}\nexport function buildInstagramDownloadItems(shortcode, items) {\n    if (!Array.isArray(items)) {\n        throw new CommandExecutionError('Instagram media metadata returned a malformed media list');\n    }\n    return items.map((item, index) => {\n        if (!item || typeof item !== 'object' || !['image', 'video'].includes(item.type)) {\n            throw new CommandExecutionError(`Instagram media metadata returned malformed media item #${index + 1}`);\n        }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/download.js#L56-L92","documentation":"Thrown by parseInstagramMediaTarget when the URL is a valid instagram.com URL but its path does not match /p/<code>/, /reel/<code>/, /tv/<code>/ (kind in SUPPORTED_KINDS at segment 0 or 1 with a following shortcode). The library only supports post, reel, and igtv links.","triggerScenarios":"Passing profile URLs (/username/), story URLs (/stories/...), explore pages, share links without the kind segment, or /p/ with a missing shortcode.","commonSituations":"Copying a profile or stories link instead of a post link; using share links (instagram.com/share/...) that don't resolve to /p/; passing the site root or an explore URL.","solutions":["Open the specific post/reel and copy its /p/<shortcode>/, /reel/<shortcode>/ or /tv/<shortcode>/ URL","Resolve share/profile links to the underlying post URL first","Trim tracking query strings and extra path segments that break segment matching"],"exampleFix":"// before\nhttps://www.instagram.com/someuser/\n// after\nhttps://www.instagram.com/p/Cxyz123/","handlingStrategy":"validation","validationCode":"const m = new URL(raw).pathname.match(/^\\/(p|reel|tv)\\/([A-Za-z0-9_-]+)\\/?/);\nif (!m) throw new Error('Only /p/, /reel/, /tv/ post links are supported');","typeGuard":"function isPostLink(v) {\n  try { return /^\\/(p|reel|tv)\\/[A-Za-z0-9_-]+\\/?$/.test(new URL(v).pathname); } catch { return false; }\n}","tryCatchPattern":"try {\n  await igDownload(raw);\n} catch (e) {\n  if (e.name === 'ArgumentError' && /Unsupported Instagram media URL/.test(e.message)) {\n    console.error('This looks like a profile/story/share link; open the post itself and copy its /p/ or /reel/ URL.');\n  } else throw e;\n}","preventionTips":["Copy the link from inside a specific post, not from a profile page or share sheet","Strip query strings and extra path segments","Only use post, reel, or IGTV links"],"tags":["cli","url-parsing","unsupported-link-type"],"backgroundTag":"unsupported-url-path","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}