{"record":{"id":"541c422242f3149e","repo":"tonhowtf/omniget","slug":"no-m-ximo-trechos-por-envio","errorCode":null,"errorMessage":"no máximo {} trechos por envio","messagePattern":"no máximo (.+?) trechos por envio","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/sponsorblock.rs","lineNumber":211,"sourceCode":"    #[serde(default = \"default_action\")]\n    pub action_type: String,\n    /// Só o capítulo usa: é o título que aparece na barra.\n    #[serde(default)]\n    pub description: String,\n}\n\nfn default_action() -> String {\n    \"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","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/sponsorblock.rs#L193-L229","documentation":"Guard in `validate_segments` limiting submissions to MAX_SEGMENTS_PER_SUBMIT segments. SponsorBlock submissions carry a bounded number of segments per request; exceeding the constant is rejected locally to avoid wasting a rate-limited attempt.","triggerScenarios":"Calling `validate_segments` (or `build_payload`) with more segments than MAX_SEGMENTS_PER_SUBMIT in the slice — typically a batched import or a user who marked many segments at once.","commonSituations":"Bulk-importing segments exported from another tool; automation looping and appending duplicate segments; users marking dozens of chapter/sponsor ranges in one go.","solutions":["Split the submission into multiple payloads of at most MAX_SEGMENTS_PER_SUBMIT segments each.","Deduplicate and merge overlapping segments before validating.","Check MAX_SEGMENTS_PER_SUBMIT in the source and cap the UI's segment count to that value."],"exampleFix":"// before\nvalidate_segments(&all_segments, duration)?;\n// after\nfor chunk in all_segments.chunks(MAX_SEGMENTS_PER_SUBMIT) {\n    validate_segments(chunk, duration)?;\n}","handlingStrategy":"validation","validationCode":"assert!(segments.len() <= MAX_SEGMENTS_PER_SUBMIT, \"too many segments for one submit\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap the UI's segment count at MAX_SEGMENTS_PER_SUBMIT.","Chunk large imports into multiple submissions.","Deduplicate/merge overlapping segments first."],"tags":["validation","sponsorblock","limit"],"backgroundTag":"value-out-of-range","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"}