{"record":{"id":"1a00578bbf4c7c16","repo":"tonhowtf/omniget","slug":"trecho-categoria-desconhecida","errorCode":null,"errorMessage":"trecho {}: categoria desconhecida ({})","messagePattern":"trecho (.+?): categoria desconhecida \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/sponsorblock.rs","lineNumber":219,"sourceCode":"    \"skip\".to_string()\n}\n\n/// Recusa o que o servidor recusaria, com a mensagem em português e antes de\n/// gastar um envio (o limite de taxa é por conta, não por tentativa válida).\npub fn validate_segments(segments: &[NewSegment], duration: f64) -> anyhow::Result<()> {\n    if segments.is_empty() {\n        return Err(anyhow!(\"marque pelo menos um trecho antes de enviar\"));\n    }\n    if segments.len() > MAX_SEGMENTS_PER_SUBMIT {\n        return Err(anyhow!(\n            \"no máximo {} trechos por envio\",\n            MAX_SEGMENTS_PER_SUBMIT\n        ));\n    }\n    for (i, s) in segments.iter().enumerate() {\n        let n = i + 1;\n        if !CATEGORIES.contains(&s.category.as_str()) {\n            return Err(anyhow!(\n                \"trecho {}: categoria desconhecida ({})\",\n                n,\n                s.category\n            ));\n        }\n        if !ACTION_TYPES.contains(&s.action_type.as_str()) {\n            return Err(anyhow!(\n                \"trecho {}: tipo de ação desconhecido ({})\",\n                n,\n                s.action_type\n            ));\n        }\n        if !s.start.is_finite() || !s.end.is_finite() || s.start < 0.0 || s.end < 0.0 {\n            return Err(anyhow!(\"trecho {}: tempo inválido\", n));\n        }\n        let pontual = s.action_type == \"poi\" || s.action_type == \"full\";\n        if !pontual && s.end <= s.start {\n            return Err(anyhow!(\"trecho {}: o fim tem de vir depois do começo\", n));","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/sponsorblock.rs#L201-L237","documentation":"Per-segment enum check in `validate_segments`: each segment's category must be one of the strings in the CATEGORIES whitelist (the SponsorBlock category set the library supports). Any other string fails with the 1-based segment number and the offending value.","triggerScenarios":"Calling `validate_segments`/`build_payload` with a segment whose `category` is misspelled, capitalized differently (e.g. \"Sponsor\"), or simply not in CATEGORIES (e.g. \" filler\", \"highlight\" if unsupported).","commonSituations":"Hand-writing category strings instead of copying the constants; importing segments from another tool with different category names; locale-mangled strings; older/newer SponsorBlock category names than the library's list.","solutions":["Use a category string from the library's CATEGORIES list (check the constant in sponsorblock.rs) exactly, lowercase.","Copy category names from the SponsorBlock API docs matching the library's supported version.","Trim/normalize user input to lowercase before constructing NewSegment.","If a legitimate new category is missing, add it to CATEGORIES."],"exampleFix":"// before\nNewSegment { category: \"Sponsor\".into(), .. };\n// after\nNewSegment { category: \"sponsor\".into(), .. };","handlingStrategy":"validation","validationCode":"const CATEGORIES: &[&str] = &[\"sponsor\", \"selfpromo\", \"interaction\", \"intro\", \"outro\", \"preview\", \"music_offtopic\", \"filler\", \"chapter\"];\nassert!(CATEGORIES.contains(&seg.category.as_str()), \"unknown category: {}\", seg.category);","typeGuard":"fn is_valid_category(c: &str) -> bool {\n    CATEGORIES.contains(&c.to_lowercase().trim())\n}","tryCatchPattern":null,"preventionTips":["Copy category strings from the library's CATEGORIES constant, lowercase.","Trim+lowercase user input before building NewSegment.","Don't invent category names from memory — check the SponsorBlock docs version the library targets."],"tags":["validation","enum","sponsorblock"],"backgroundTag":"invalid-enum-value","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}