jackwener/OpenCLI · error · ArgumentError
Unsupported Instagram media URL: ${raw}
Error message
Unsupported Instagram media URL: ${raw} What it means
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.
Source
Thrown at clis/instagram/download.js:74
throw new ArgumentError(`Unsupported URL protocol: ${url.protocol}`);
}
const host = url.hostname.toLowerCase();
if (host !== INSTAGRAM_HOST_SUFFIX && !host.endsWith(`.${INSTAGRAM_HOST_SUFFIX}`)) {
throw new ArgumentError(`Unsupported host: ${host}`, 'Only instagram.com URLs are supported');
}
const segments = url.pathname.split('/').filter(Boolean);
let kind;
let shortcode;
if (segments.length >= 2 && SUPPORTED_KINDS.has(segments[0])) {
kind = segments[0];
shortcode = segments[1];
}
else if (segments.length >= 3 && SUPPORTED_KINDS.has(segments[1])) {
kind = segments[1];
shortcode = segments[2];
}
if (!kind || !shortcode) {
throw new ArgumentError(`Unsupported Instagram media URL: ${raw}`, 'Only /p/<shortcode>/, /reel/<shortcode>/, and /tv/<shortcode>/ links are supported');
}
if (!shortcodeToMediaId(shortcode)) {
throw new ArgumentError(`Invalid Instagram shortcode: ${shortcode}`, 'Copy the link straight from the post, without escaping it');
}
return {
kind: kind,
shortcode,
canonicalUrl: `https://www.instagram.com/${kind}/${shortcode}/`,
};
}
export function buildInstagramDownloadItems(shortcode, items) {
if (!Array.isArray(items)) {
throw new CommandExecutionError('Instagram media metadata returned a malformed media list');
}
return items.map((item, index) => {
if (!item || typeof item !== 'object' || !['image', 'video'].includes(item.type)) {
throw new CommandExecutionError(`Instagram media metadata returned malformed media item #${index + 1}`);
}View on GitHub (pinned to 49907e53dc)
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
Example fix
// before https://www.instagram.com/someuser/ // after https://www.instagram.com/p/Cxyz123/
Defensive patterns
Strategy: validation
Validate before calling
const m = new URL(raw).pathname.match(/^\/(p|reel|tv)\/([A-Za-z0-9_-]+)\/?/);
if (!m) throw new Error('Only /p/, /reel/, /tv/ post links are supported'); Type guard
function isPostLink(v) {
try { return /^\/(p|reel|tv)\/[A-Za-z0-9_-]+\/?$/.test(new URL(v).pathname); } catch { return false; }
} Try / catch
try {
await igDownload(raw);
} catch (e) {
if (e.name === 'ArgumentError' && /Unsupported Instagram media URL/.test(e.message)) {
console.error('This looks like a profile/story/share link; open the post itself and copy its /p/ or /reel/ URL.');
} else throw e;
} Prevention
- 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
When it happens
Trigger: Passing profile URLs (/username/), story URLs (/stories/...), explore pages, share links without the kind segment, or /p/ with a missing shortcode.
Common situations: 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.
Related errors
- --url must be a Discord channel URL like https://discord.com
- --url must be a Discord thread/post URL like https://discord
- id not a valid Grok URL (got "${input}")
- event query parameter must be a numeric event id
- event must be an event id, an /events/:id URL, a stats URL w
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3083678a7d0e7624.
Report an issue: GitHub.