tonhowtf/omniget · error

resposta sem comentários (o VOD tem replay de chat?)

Error message

resposta sem comentários (o VOD tem replay de chat?)

What it means

parse_page reads the batched persisted-query response for VOD chat comments. It throws when the JSON has no /data/video/comments path (or it is null), which the library interprets as the VOD having no chat replay. This is a defensive guard so callers get a clear message instead of a cryptic null-pointer failure.

Solutions

  1. Verify the VOD actually has chat replay by checking the video's comment section in a browser
  2. Enable/keep 'Add chat replay' on the channel for future broadcasts — nothing can be recovered for past VODs
  3. Use a different VOD id; confirm the id is correct and the video is not sub-only or expired
  4. Handle this error as 'no chat available' in the caller instead of retrying

Example fix

// before
let page = fetch_all(&vod_id).await?;
// after
match fetch_all(&vod_id).await {
    Ok(page) => println!("{} comments", page.messages.len()),
    Err(e) if e.to_string().contains("replay de chat") => eprintln!("VOD has no chat replay"),
    Err(e) => return Err(e),
}
Defensive patterns

Strategy: try-catch

Validate before calling

// No pre-call check possible: chat replay availability is server-side.
// Optionally verify the VOD page shows comments before invoking.

Type guard

fn has_chat_replay(raw: &serde_json::Value) -> bool {
    raw.pointer("/data/video/comments").map_or(false, |v| !v.is_null())
}

Try / catch

match fetch_all(&vod_id).await {
    Ok(page) => process(page),
    Err(e) if e.to_string().contains("replay de chat") => {
        eprintln!("This VOD has no chat replay");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling fetch_all / msgs (or anything that calls parse_page) against a Twitch VOD whose chat replay is unavailable: the persisted query succeeds but data.video.comments is missing or null.

Common situations: Downloading chat for old VODs where replay was disabled or deleted by the broadcaster; VODs from before chat replay existed; streams where the channel enabled 'add chat replay' off; passing a VOD id with an expired/unavailable video (sometimes returns null comments instead of an error).

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/twitch/chat.rs:133

    /// Amostra para a UI mostrar sem carregar tudo.
    pub sample: Vec<Message>,
}

// ───────────────────────── parsing ─────────────────────────

#[derive(Debug, Clone, Default)]
pub struct Page {
    pub messages: Vec<Message>,
    pub cursor: Option<String>,
    pub has_next: bool,
}

/// Lê um elemento da resposta em lote da persisted query.
pub fn parse_page(raw: &Value) -> anyhow::Result<Page> {
    let comments = raw
        .pointer("/data/video/comments")
        .filter(|v| !v.is_null())
        .ok_or_else(|| anyhow!("resposta sem comentários (o VOD tem replay de chat?)"))?;
    let edges = comments
        .get("edges")
        .and_then(|v| v.as_array())
        .cloned()
        .unwrap_or_default();
    let mut messages = Vec::with_capacity(edges.len());
    let mut cursor = None;
    for edge in &edges {
        if let Some(c) = edge.get("cursor").and_then(|v| v.as_str()) {
            cursor = Some(c.to_string());
        }
        let Some(node) = edge.get("node") else {
            continue;
        };
        let Some(msg) = parse_message(node) else {
            continue;
        };
        messages.push(msg);

View on GitHub (pinned to 8600b91f42)