tonhowtf/omniget · error

o container falhou

Error message

o container falhou: {}

What it means

wait_container polls a media container's status_code until it finishes. If the container reports ERROR or EXPIRED, publishing can never proceed, so the helper aborts with "o container falhou: <status>" including the container's descriptive status field. This means Instagram rejected the uploaded container itself, not the final publish call.

Solutions

  1. Read the included status string to see Instagram's reason (e.g. "Video file is invalid")
  2. Re-encode the video to Instagram-recommended specs (MP4/H.264, AAC, within duration limits) and retry
  3. Ensure the source URL stays publicly reachable and publish the container promptly after creation

Example fix

// before
let container = create_container(url).await?;
tokio::time::sleep(Duration::from_secs(3600)).await; // container expired
wait_container(&http, &container, &token).await?; // Err: o container falhou: Expired
// after
let container = create_container(url).await?;
wait_container(&http, &container, &token).await?; // poll immediately
publish(&container).await?;
Defensive patterns

Strategy: validation

Validate before calling

// validate video against Instagram specs before creating a container
assert!(duration_secs <= 90.0 && width % 4 == 0 && height % 4 == 0);
assert!(head_request(url).status == 200, "source URL must be publicly reachable");

Try / catch

match wait_container(&http, &id, &token).await {
    Err(e) if e.to_string().contains("o container falhou") => {
        log::error!("container rejected: {e}; re-encode media and retry");
        reencode_and_recreate_container().await
    }
    r => r,
}

Prevention

When it happens

Trigger: During publish_graph, a container created via POST /media reaches status_code ERROR or EXPIRED while being polled every 5 seconds — e.g. a video that fails Instagram's transcoding/validation or a container left unpublished too long.

Common situations: Video exceeds Instagram's specs (duration, aspect ratio, codec); source URL returned 403/404 during container processing; container created but media_publish delayed beyond its expiry.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/instagram/publish.rs:584

                .unwrap_or("erro")
        ));
    }
    Ok(json)
}

async fn wait_container(http: &reqwest::Client, id: &str, token: &str) -> anyhow::Result<()> {
    for _ in 0..40 {
        let st = graph_get(
            http,
            &format!(
                "{}/{}?fields=status_code,status&access_token={}",
                GRAPH, id, token
            ),
        )
        .await?;
        match s(&st, "status_code").as_str() {
            "FINISHED" => return Ok(()),
            "ERROR" | "EXPIRED" => return Err(anyhow!("o container falhou: {}", s(&st, "status"))),
            _ => tokio::time::sleep(std::time::Duration::from_secs(5)).await,
        }
    }
    Err(anyhow!("o Instagram demorou demais para processar a midia"))
}

/// Publica pela API oficial. `req.files` são URLs públicas.
pub async fn publish_graph(
    auth: &GraphAuth,
    req: &PublishRequest,
    progress: &super::super::ProgressFn,
    job: &str,
) -> anyhow::Result<PublishResult> {
    let id = format!("ig:{}", job);
    let http = super::super::client()?;
    let token = auth.access_token.trim().to_string();
    let user = auth.ig_user_id.trim().to_string();
    if token.is_empty() || user.is_empty() {

View on GitHub (pinned to 8600b91f42)