tonhowtf/omniget · error

trecho : tipo de ação desconhecido ( )

Error message

trecho {}: tipo de ação desconhecido ({})

What it means

Per-segment enum check in `validate_segments`: each segment's `action_type` must be one of the strings in ACTION_TYPES (the SponsorBlock action whitelist the library supports, e.g. "skip", "mute", "full", "poi", "chapter"). Unknown values fail with the segment number and offending value.

Solutions

  1. Use an action_type string present in the library's ACTION_TYPES constant, exactly and lowercase.
  2. Normalize input with trim+lowercase before building NewSegment.
  3. If the server supports a new action type, add it to ACTION_TYPES and rebuild.

Example fix

// before
NewSegment { action_type: "Skip".into(), .. };
// after
NewSegment { action_type: "skip".into(), .. };
Defensive patterns

Strategy: validation

Validate before calling

const ACTION_TYPES: &[&str] = &["skip", "mute", "full", "poi", "chapter"];
assert!(ACTION_TYPES.contains(&seg.action_type.as_str()), "unknown action: {}", seg.action_type);

Type guard

fn is_valid_action(a: &str) -> bool {
    ACTION_TYPES.contains(&a.to_lowercase().trim())
}

Prevention

When it happens

Trigger: Calling `validate_segments`/`build_payload` with a segment whose `action_type` is misspelled, wrong-cased, or not in ACTION_TYPES (e.g. "skip_only", "chapter" if unsupported by the local list).

Common situations: Copying action names from a newer/older SponsorBlock API version; typo like "poi" vs "pointOfInterest" variants; hand-crafted JSON payloads imported from other tools.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/sponsorblock.rs:226

        return Err(anyhow!("marque pelo menos um trecho antes de enviar"));
    }
    if segments.len() > MAX_SEGMENTS_PER_SUBMIT {
        return Err(anyhow!(
            "no máximo {} trechos por envio",
            MAX_SEGMENTS_PER_SUBMIT
        ));
    }
    for (i, s) in segments.iter().enumerate() {
        let n = i + 1;
        if !CATEGORIES.contains(&s.category.as_str()) {
            return Err(anyhow!(
                "trecho {}: categoria desconhecida ({})",
                n,
                s.category
            ));
        }
        if !ACTION_TYPES.contains(&s.action_type.as_str()) {
            return Err(anyhow!(
                "trecho {}: tipo de ação desconhecido ({})",
                n,
                s.action_type
            ));
        }
        if !s.start.is_finite() || !s.end.is_finite() || s.start < 0.0 || s.end < 0.0 {
            return Err(anyhow!("trecho {}: tempo inválido", n));
        }
        let pontual = s.action_type == "poi" || s.action_type == "full";
        if !pontual && s.end <= s.start {
            return Err(anyhow!("trecho {}: o fim tem de vir depois do começo", n));
        }
        if s.action_type == "chapter" && s.description.trim().is_empty() {
            return Err(anyhow!("trecho {}: capítulo precisa de um título", n));
        }
        if duration > 0.0 && s.end > duration + 1.0 {
            return Err(anyhow!("trecho {}: passa do fim do vídeo", n));
        }

View on GitHub (pinned to 8600b91f42)