tonhowtf/omniget · error · anyhow::Error

No media found in post

Error message

No media found in post

What it means

Raised by `extract_media_from_gql` when a successfully parsed Instagram GraphQL response contains no media nodes — none of the video_url / display_url / edge_sidecar_to_children fields the function inspects are present. It signals a structurally-valid GraphQL payload that simply has no downloadable media for this post.

Solutions

  1. Confirm the post is still live and public on instagram.com before retrying
  2. Log the raw GraphQL JSON to inspect which field names changed, then update the extraction paths in `extract_media_from_gql`
  3. Fall back to `request_embed`/`fallback_ytdlp` when GraphQL extraction returns this error
  4. Attach authenticated cookies/session headers so Instagram returns the full GraphQL payload instead of a redacted one

Example fix

// before
let media = self.extract_media_from_gql(&gql_json)?;
// after
let media = match self.extract_media_from_gql(&gql_json) {
    Ok(m) => m,
    Err(e) => {
        tracing::warn!("gql extraction empty: {e:#}; trying embed");
        self.request_embed(&post_id).await?.into()
    }
};
Defensive patterns

Strategy: fallback

Validate before calling

fn gql_has_media(gql: &serde_json::Value) -> bool {
    gql["data"]["shortcode_media"].is_object()
        || gql["display_url"].is_string()
        || gql["video_url"].is_string()
        || gql["edge_sidecar_to_children"].is_object()
}

Type guard

fn is_media_present(v: &serde_json::Value) -> bool {
    v.get("display_url").is_some()
        || v.get("video_url").is_some()
        || v.get("edge_sidecar_to_children").is_some()
}

Try / catch

match extract_media_from_gql(&gql) {
    Ok(m) => m,
    Err(e) if e.to_string().contains("No media found in post") => {
        tracing::warn!("gql payload had no media; trying embed path");
        extract_media_from_embed(&html)?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `extract_media_from_gql` on a GraphQL JSON object that lacks `shortcode_media` media fields: private/deleted post, a post type the extractor doesn't recognize (e.g. IGTV variants or new post types), or Instagram returning an empty/partial GraphQL payload after an API shape change.

Common situations: Instagram silently changes GraphQL field names (`display_url` → new key); the post was deleted between URL fetch and GraphQL call; unauthenticated GraphQL requests get a truncated response; sharing an album whose children use a new structure.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/45e2665d3efe227c. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/instagram/mod.rs:539

                }
            }
        }

        if let Some(video_url) = data.get("video_url").and_then(|v| v.as_str()) {
            return Ok(InstagramMedia::Single {
                url: video_url.to_string(),
                is_video: true,
            });
        }

        if let Some(display_url) = data.get("display_url").and_then(|v| v.as_str()) {
            return Ok(InstagramMedia::Single {
                url: display_url.to_string(),
                is_video: false,
            });
        }

        Err(anyhow!("No media found in post"))
    }

    fn instagram_headers() -> reqwest::header::HeaderMap {
        let mut headers = reqwest::header::HeaderMap::new();
        headers.insert(
            reqwest::header::REFERER,
            "https://www.instagram.com/".parse().unwrap(),
        );
        headers.insert(
            reqwest::header::ORIGIN,
            "https://www.instagram.com".parse().unwrap(),
        );
        headers
    }

    fn post_url_from_title(title: &str) -> Option<String> {
        let post_id = title.strip_prefix("instagram_")?;
        if post_id.is_empty() {

View on GitHub (pinned to 8600b91f42)