{"record":{"id":"29060eacf2e9e92d","repo":"tonhowtf/omniget","slug":"informe-o-token-e-o-id-da-conta-do-instagram","errorCode":null,"errorMessage":"informe o token e o ID da conta do Instagram","messagePattern":"informe o token e o ID da conta do Instagram","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/publish.rs","lineNumber":603,"sourceCode":"            _ => tokio::time::sleep(std::time::Duration::from_secs(5)).await,\n        }\n    }\n    Err(anyhow!(\"o Instagram demorou demais para processar a midia\"))\n}\n\n/// Publica pela API oficial. `req.files` são URLs públicas.\npub async fn publish_graph(\n    auth: &GraphAuth,\n    req: &PublishRequest,\n    progress: &super::super::ProgressFn,\n    job: &str,\n) -> anyhow::Result<PublishResult> {\n    let id = format!(\"ig:{}\", job);\n    let http = super::super::client()?;\n    let token = auth.access_token.trim().to_string();\n    let user = auth.ig_user_id.trim().to_string();\n    if token.is_empty() || user.is_empty() {\n        return Err(anyhow!(\"informe o token e o ID da conta do Instagram\"));\n    }\n    if req.files.is_empty() || !req.files.iter().all(|f| f.starts_with(\"http\")) {\n        return Err(anyhow!(\n            \"a API oficial so aceita URLs publicas (https://…) para os arquivos\"\n        ));\n    }\n    let media_url = format!(\"{}/{}/media\", GRAPH, user);\n    let is_video = |f: &str| {\n        f.split('?')\n            .next()\n            .unwrap_or(f)\n            .to_lowercase()\n            .ends_with(\".mp4\")\n            || f.to_lowercase().ends_with(\".mov\")\n    };\n    let creation_id = match req.kind.as_str() {\n        \"carousel\" => {\n            let total = req.files.len() as u64 + 2;","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/publish.rs#L585-L621","documentation":"publish_graph requires both an access token and an Instagram user ID in GraphAuth. Before any network call it trims both fields and, if either is empty, fails fast with \"informe o token e o ID da conta do Instagram\" (provide the token and the Instagram account ID). This is a required-input validation to avoid sending doomed requests to the Graph API.","triggerScenarios":"Calling publish_graph with a GraphAuth where access_token or ig_user_id is empty or whitespace-only — e.g. credentials not yet configured in the UI/settings store and defaults passed through.","commonSituations":"User never connected their Instagram account; settings saved before OAuth completed; config struct constructed with Default; migration lost stored credentials.","solutions":["Populate GraphAuth.access_token with a valid long-lived Instagram token before calling publish_graph","Set GraphAuth.ig_user_id to the numeric ID of the Business/Creator Instagram account","In the UI, gate the publish action on completed OAuth setup so empty credentials never reach the API"],"exampleFix":"// before\nlet auth = GraphAuth::default();\npublish_graph(&auth, &req).await?; // Err: informe o token e o ID da conta do Instagram\n// after\nlet auth = GraphAuth { access_token: load_token()?, ig_user_id: load_ig_user_id()? };\npublish_graph(&auth, &req).await?;","handlingStrategy":"validation","validationCode":"if auth.access_token.trim().is_empty() || auth.ig_user_id.trim().is_empty() {\n    return Err(\"configure o token e o ID da conta do Instagram antes de publicar\");\n}","typeGuard":"fn has_graph_credentials(auth: &GraphAuth) -> bool {\n    !auth.access_token.trim().is_empty() && !auth.ig_user_id.trim().is_empty()\n}","tryCatchPattern":null,"preventionTips":["Gate the publish UI on a completed OAuth/connect flow","Persist credentials and warn at startup if they are missing","Never construct GraphAuth::default() in publish paths"],"tags":["instagram","credentials","validation"],"backgroundTag":"missing-credentials","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"}