tonhowtf/omniget · error
marque pelo menos um trecho antes de enviar
Error message
marque pelo menos um trecho antes de enviar
What it means
Client-side pre-flight check in `validate_segments` that rejects an empty segments list. It mirrors what the SponsorBlock server would reject anyway, so the failure surfaces in Portuguese before spending a submission against the per-account rate limit.
Solutions
- Ensure at least one NewSegment with valid start/end times is present before calling build_payload/validate_segments.
- In the UI, disable the submit button until a segment is marked.
- If validating in a test, populate the segments slice with sample data.
Example fix
// before
validate_segments(&[], duration)?;
// after
let segs = vec![NewSegment { category: "sponsor".into(), action_type: "skip".into(), start: 10.0, end: 30.0, description: String::new() }];
validate_segments(&segs, duration)?; Defensive patterns
Strategy: validation
Validate before calling
if segments.is_empty() {
return Err("mark at least one segment before submitting".into());
} Prevention
- Disable the submit button until at least one segment is marked.
- Never call build_payload with a programmatically empty Vec.
- Validate UI state before constructing the payload.
When it happens
Trigger: Calling `validate_segments(&[], duration)` (directly or via `build_payload`) when the user submitted a segment submission with no marked segments.
Common situations: UI bug clearing the segment list before submit; user clicking 'send' before dragging any timestamps; programmatic callers passing an empty Vec.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- informe um appid, um link da loja ou marque a biblioteca…
- a legenda nao tem falas
- texto vazio
- escolha ao menos uma imagem
- nenhuma imagem
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/4d9e425bb88e8d62.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/sponsorblock.rs:208
pub start: f64,
pub end: f64,
pub category: String,
#[serde(default = "default_action")]
pub action_type: String,
/// Só o capítulo usa: é o título que aparece na barra.
#[serde(default)]
pub description: String,
}
fn default_action() -> String {
"skip".to_string()
}
/// Recusa o que o servidor recusaria, com a mensagem em português e antes de
/// gastar um envio (o limite de taxa é por conta, não por tentativa válida).
pub fn validate_segments(segments: &[NewSegment], duration: f64) -> anyhow::Result<()> {
if segments.is_empty() {
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!(View on GitHub (pinned to 8600b91f42)