tonhowtf/omniget · error

escolha pelo menos um arquivo

Error message

escolha pelo menos um arquivo

What it means

publish_web validates that the PublishRequest contains at least one file before doing any upload; an empty req.files list immediately fails with 'escolha pelo menos um arquivo' (choose at least one file).

Solutions

  1. Check req.files is non-empty in the UI/API layer before calling publish_web
  2. Ensure the client serializes the files array correctly
  3. Return a validation error to the user prompting a file selection

Example fix

// before
// calling publish_web directly with an empty request
// after
if (req.files.length === 0) { alert('escolha pelo menos um arquivo'); return; }
Defensive patterns

Strategy: validation

Validate before calling

if (!req.files || req.files.length === 0) {
  throw new Error('escolha pelo menos um arquivo');
}

Type guard

function hasFiles(req) { return Array.isArray(req.files) && req.files.length > 0; }

Try / catch

try { await publish_web(req) } catch (e) { if (String(e).includes('escolha pelo menos um arquivo')) { promptFileSelection(); } else { throw e; } }

Prevention

When it happens

Trigger: Calling publish_web with kind photo/video/carousel and req.files == [].

Common situations: Frontend sends a publish request before the user selected files, or a file-picker bug drops the selection from the payload.

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/c3531292c3404359. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/instagram/publish.rs:303

            if req.hide_like_counts { "1" } else { "0" }.into(),
        ),
        ("custom_accessibility_caption", req.alt_text.clone()),
        ("usertags", "".into()),
        ("archive_only", "false".into()),
        ("is_meta_only_post", "0".into()),
    ]
}

/// Publica pela sessão web.
pub async fn publish_web(
    client: &IgClient,
    req: &PublishRequest,
    progress: &super::super::ProgressFn,
    job: &str,
) -> anyhow::Result<PublishResult> {
    let id = format!("ig:{}", job);
    if req.files.is_empty() {
        return Err(anyhow!("escolha pelo menos um arquivo"));
    }
    let report = |stage: &str, done: u64, total: u64| {
        super::super::report(progress, &id, stage, done, Some(total), None)
    };
    let m = |e: IgError| anyhow!(e.to_string());
    match req.kind.as_str() {
        "photo" => {
            report("upload", 0, 2);
            let uid = upload_id();
            let (bytes, w, h) = as_jpeg(Path::new(&req.files[0])).await?;
            rupload_photo(client, bytes, w, h, &uid, &[])
                .await
                .map_err(m)?;
            report("configure", 1, 2);
            let json = client
                .post_form("/api/v1/media/configure/", &common_form(req, &uid))
                .await
                .map_err(m)?;

View on GitHub (pinned to 8600b91f42)