tonhowtf/omniget · error · IgError

e.to_string()

Error message

e.to_string()

What it means

publish_web defines a local mapper m = |e: IgError| anyhow!(e.to_string()) used to convert Instagram client errors into anyhow errors at each upload/configure step; the surfaced message is the Display of the underlying IgError.

Solutions

  1. Read the stringified IgError to identify auth vs upload vs HTTP failure
  2. Refresh Instagram login/session credentials if auth-related
  3. Retry transient failures with backoff; respect rate limits
  4. Validate media constraints (aspect ratio, duration, size) before upload
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate session and media before publish
assert_session_valid(client)?;
validate_media_constraints(&req.files)?;

Try / catch

match publish_web(req, progress, job).await { Err(e) => { log::error!("publish failed: {e}"); if e.to_string().to_lowercase().contains("login") { reauth()?; } else { return Err(e); } }, ok => ok }

Prevention

When it happens

Trigger: Any Instagram API call inside publish_web (photo upload, video upload, carousel items, configure) returning Err(IgError) other than the special transcode/202 cases.

Common situations: Instagram session expired, media upload rejected (bad dimensions/duration), rate limiting, or transient HTTP failures during rupload.

Related errors


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

Appendix: source

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

        ("is_meta_only_post", "0".into()),
    ]
}

/// Publica pela sessão web.
pub async fn publish_web(
    client: &IgClient,
    req: &PublishRequest,
    progress: &super::super::ProgressFn,
    job: &str,
) -> anyhow::Result<PublishResult> {
    let id = format!("ig:{}", job);
    if req.files.is_empty() {
        return Err(anyhow!("escolha pelo menos um arquivo"));
    }
    let report = |stage: &str, done: u64, total: u64| {
        super::super::report(progress, &id, stage, done, Some(total), None)
    };
    let m = |e: IgError| anyhow!(e.to_string());
    match req.kind.as_str() {
        "photo" => {
            report("upload", 0, 2);
            let uid = upload_id();
            let (bytes, w, h) = as_jpeg(Path::new(&req.files[0])).await?;
            rupload_photo(client, bytes, w, h, &uid, &[])
                .await
                .map_err(m)?;
            report("configure", 1, 2);
            let json = client
                .post_form("/api/v1/media/configure/", &common_form(req, &uid))
                .await
                .map_err(m)?;
            report("done", 2, 2);
            Ok(result_of(&json))
        }
        "story" => {
            let path = Path::new(&req.files[0]);

View on GitHub (pinned to 8600b91f42)