tonhowtf/omniget · error · anyhow::Error

informe o perfil (@usuario) ou a URL da coleção

Error message

informe o perfil (@usuario) ou a URL da coleção

What it means

The TikTok favorites downloader requires either a profile (@username) or a collection URL to know which favorites to fetch. `run` validates `opts.user` up front and aborts with this Portuguese-language message when it is empty or only whitespace. It is a deliberate fail-fast guard so the tool never starts a download with no target.

Solutions

  1. Set opts.user to the @username or the collection URL before calling run.
  2. In the UI, disable the download action until the profile/URL field is non-empty after trimming.
  3. If the field is optional by design, resolve a default user upstream instead of passing an empty string.

Example fix

// before
let opts = Options { dest: "/tmp/out".into(), ..Default::default() };
// after
let opts = Options { user: "@someuser".into(), dest: "/tmp/out".into(), ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

// Rust caller
if opts.user.trim().is_empty() {
    return Err(anyhow!("informe o perfil (@usuario) ou a URL da coleção antes de iniciar"));
}

Type guard

fn has_user(opts: &Options) -> bool { !opts.user.trim().is_empty() }

Prevention

When it happens

Trigger: Calling `run(opts, progress)` with `opts.user` set to "" or a whitespace-only string; constructing Options programmatically and forgetting to fill the user/collection-URL field; a frontend binding that sends an empty string instead of None.

Common situations: A desktop (Tauri) UI invokes the command before the user typed the profile; a script builds Options with Default::default() and never sets user; form input is trimmed and becomes empty.

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


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/tiktok/favorites.rs:433

            None,
            Some(format!("{} itens", out.len())),
        );
        if vazio || !has_more || next.is_empty() || next == cursor || out.len() as u32 >= teto {
            break;
        }
        cursor = next;
    }
    if out.is_empty() {
        return Err(anyhow!(
            "a lista voltou vazia — o TikTok não entregou os favoritos para esta sessão"
        ));
    }
    Ok(out)
}

pub async fn run(opts: &Options, progress: ProgressFn) -> Result<FavoritesResult> {
    if opts.user.trim().is_empty() {
        return Err(anyhow!("informe o perfil (@usuario) ou a URL da coleção"));
    }
    if opts.dest.trim().is_empty() {
        return Err(anyhow!("escolha a pasta de destino"));
    }
    let dest = PathBuf::from(&opts.dest);
    std::fs::create_dir_all(&dest)?;

    let session = TempCookies::new(opts.session_netscape.as_deref());
    let used_session = session.is_some();
    let cookies: Option<PathBuf> = opts
        .cookies
        .as_deref()
        .filter(|c| !c.trim().is_empty())
        .map(PathBuf::from)
        .or_else(|| session.path().map(|p| p.to_path_buf()));

    let handle = handle_of(&opts.user);
    let pacer = Pacer::new(opts.delay_ms);

View on GitHub (pinned to 8600b91f42)