{"record":{"id":"bdec5a8949341db6","repo":"tonhowtf/omniget","slug":"erro-da-api","errorCode":null,"errorMessage":"Erro da API: {}","messagePattern":"Erro da API: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/bluesky.rs","lineNumber":148,"sourceCode":"        let url = format!(\n            \"{}?depth=0&parentHeight=0&uri={}\",\n            API_BASE,\n            urlencoding::encode(&uri)\n        );\n\n        let response = self.client.get(&url).send().await?;\n\n        if !response.status().is_success() {\n            return Err(anyhow!(\"Bluesky API retornou HTTP {}\", response.status()));\n        }\n\n        let json: serde_json::Value = response.json().await?;\n\n        if let Some(error) = json.get(\"error\").and_then(|e| e.as_str()) {\n            return match error {\n                \"NotFound\" | \"InternalServerError\" => Err(anyhow!(\"Post not available\")),\n                \"InvalidRequest\" => Err(anyhow!(\"Unsupported link\")),\n                _ => Err(anyhow!(\"Erro da API: {}\", error)),\n            };\n        }\n\n        Ok(json)\n    }\n}\n\nenum BlueskyMedia {\n    Video { hls_url: String },\n    Images { urls: Vec<String> },\n    Gif { url: String },\n}\n\nfn extract_media(embed: &serde_json::Value) -> Option<BlueskyMedia> {\n    let embed_type = embed.get(\"$type\")?.as_str()?;\n\n    match embed_type {\n        \"app.bsky.embed.video#view\" => {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/bluesky.rs#L130-L166","documentation":"Catch-all branch in fetch_post's error match: the Bluesky API returned an error envelope with an unrecognized error string, so it is propagated verbatim as \"Erro da API: {error}\". It signals an error type the mapping does not explicitly handle.","triggerScenarios":"Bluesky's AppView returns error codes beyond NotFound/InternalServerError/InvalidRequest, e.g. \"InvalidTokenError\", \"AuthRequiredError\", or new error kinds introduced server-side.","commonSituations":"New Bluesky API error codes after API evolution, authentication-gated content on public.api.bsky.app, or unusual server responses during incidents.","solutions":["Read the appended error string to identify the actual API error code.","Add an explicit match arm for any recurring error code to give a better message.","Retry via the yt-dlp fallback path in get_media_info if native fetching keeps failing.","Check Bluesky API status/changelog if a new error code appears en masse."],"exampleFix":"// before\n_ => Err(anyhow!(\"Erro da API: {}\", error)),\n// after\n\"ExpiredToken\" | \"InvalidTokenError\" => Err(anyhow!(\"Authentication required\")),\nother => Err(anyhow!(\"Erro da API: {}\", other)),","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match downloader.get_media_info(url).await {\n    Err(e) if e.to_string().starts_with(\"Erro da API:\") => {\n        let code = e.to_string().trim_start_matches(\"Erro da API: \").to_string();\n        log::warn!(\"unmapped bluesky API error: {}\", code);\n        // try yt-dlp fallback or surface code to user\n    }\n    other => other.map(|i| download(i)),\n}","preventionTips":["Log the appended API error code whenever this fires to extend the match arms","Keep the library updated as Bluesky adds new error codes","Use the yt-dlp fallback as a safety net for unmapped API errors"],"tags":["bluesky","api","unhandled-error"],"backgroundTag":"api-error-response","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"}