{"record":{"id":"c3531292c3404359","repo":"tonhowtf/omniget","slug":"escolha-pelo-menos-um-arquivo","errorCode":null,"errorMessage":"escolha pelo menos um arquivo","messagePattern":"escolha pelo menos um arquivo","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/publish.rs","lineNumber":303,"sourceCode":"            if req.hide_like_counts { \"1\" } else { \"0\" }.into(),\n        ),\n        (\"custom_accessibility_caption\", req.alt_text.clone()),\n        (\"usertags\", \"\".into()),\n        (\"archive_only\", \"false\".into()),\n        (\"is_meta_only_post\", \"0\".into()),\n    ]\n}\n\n/// Publica pela sessão web.\npub async fn publish_web(\n    client: &IgClient,\n    req: &PublishRequest,\n    progress: &super::super::ProgressFn,\n    job: &str,\n) -> anyhow::Result<PublishResult> {\n    let id = format!(\"ig:{}\", job);\n    if req.files.is_empty() {\n        return Err(anyhow!(\"escolha pelo menos um arquivo\"));\n    }\n    let report = |stage: &str, done: u64, total: u64| {\n        super::super::report(progress, &id, stage, done, Some(total), None)\n    };\n    let m = |e: IgError| anyhow!(e.to_string());\n    match req.kind.as_str() {\n        \"photo\" => {\n            report(\"upload\", 0, 2);\n            let uid = upload_id();\n            let (bytes, w, h) = as_jpeg(Path::new(&req.files[0])).await?;\n            rupload_photo(client, bytes, w, h, &uid, &[])\n                .await\n                .map_err(m)?;\n            report(\"configure\", 1, 2);\n            let json = client\n                .post_form(\"/api/v1/media/configure/\", &common_form(req, &uid))\n                .await\n                .map_err(m)?;","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/publish.rs#L285-L321","documentation":"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).","triggerScenarios":"Calling publish_web with kind photo/video/carousel and req.files == [].","commonSituations":"Frontend sends a publish request before the user selected files, or a file-picker bug drops the selection from the payload.","solutions":["Check req.files is non-empty in the UI/API layer before calling publish_web","Ensure the client serializes the files array correctly","Return a validation error to the user prompting a file selection"],"exampleFix":"// before\n// calling publish_web directly with an empty request\n// after\nif (req.files.length === 0) { alert('escolha pelo menos um arquivo'); return; }","handlingStrategy":"validation","validationCode":"if (!req.files || req.files.length === 0) {\n  throw new Error('escolha pelo menos um arquivo');\n}","typeGuard":"function hasFiles(req) { return Array.isArray(req.files) && req.files.length > 0; }","tryCatchPattern":"try { await publish_web(req) } catch (e) { if (String(e).includes('escolha pelo menos um arquivo')) { promptFileSelection(); } else { throw e; } }","preventionTips":["Disable the publish button until files are selected","Validate the request payload in the UI layer","Serialize the files array explicitly in the client"],"tags":["validation","input-validation","instagram","rust"],"backgroundTag":"empty-required-field","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}