From d449eb007cf73d86adb782b8bf05f6bd1459a554 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 13 Jun 2025 22:47:04 -0400 Subject: [PATCH] fix fal client errors --- Cargo.lock | 1 + crates/lib/api_clients/fal_client/Cargo.toml | 1 + .../src/requests/queue/remove_background_rembg.rs | 9 +++++---- crates/vendor/fal-rs/src/queue.rs | 7 +++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df6854720c..62703108f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3598,6 +3598,7 @@ dependencies = [ "fal", "file_to_base64_url", "futures 0.3.31", + "log", "reqwest 0.12.15", "serde", "testing", diff --git a/crates/lib/api_clients/fal_client/Cargo.toml b/crates/lib/api_clients/fal_client/Cargo.toml index 16912f0fa9..3fbe4cdba1 100644 --- a/crates/lib/api_clients/fal_client/Cargo.toml +++ b/crates/lib/api_clients/fal_client/Cargo.toml @@ -23,6 +23,7 @@ errors = { workspace = true } # External anyhow = { workspace = true } futures = { workspace = true } +log = { workspace = true } reqwest = { workspace = true } serde = { workspace = true } tokio = { workspace = true } diff --git a/crates/lib/api_clients/fal_client/src/requests/queue/remove_background_rembg.rs b/crates/lib/api_clients/fal_client/src/requests/queue/remove_background_rembg.rs index 9a6632ee2b..cd464fbb9b 100644 --- a/crates/lib/api_clients/fal_client/src/requests/queue/remove_background_rembg.rs +++ b/crates/lib/api_clients/fal_client/src/requests/queue/remove_background_rembg.rs @@ -22,7 +22,7 @@ pub async fn remove_background_rembg>(image_path: P, api_key: &Fa crop_to_bbox: None, sync_mode: None }; - + let result = rembg(request) .with_api_key(&api_key.0) .queue() @@ -56,6 +56,7 @@ mod tests { use crate::creds::fal_api_key::FalApiKey; use crate::requests::queue::remove_background_rembg::remove_background_rembg; use errors::AnyhowResult; + use std::fs::read_to_string; use testing::test_file_path::test_file_path; #[tokio::test] @@ -63,9 +64,9 @@ mod tests { async fn test_remove_background_rembg() -> AnyhowResult<()> { let image = test_file_path("test_data/image/juno.jpg")?; - // TODO: DO NOT COMMIT SECRET ! - const KEY : &str = "DO NOT COMMIT"; - let api_key = FalApiKey::from_str(KEY); + // XXX: Don't commit secrets! + let secret = read_to_string("/Users/bt/Artcraft/credentials/fal_api_key.txt")?; + let api_key = FalApiKey::from_str(&secret); let result = remove_background_rembg(image, &api_key).await?; diff --git a/crates/vendor/fal-rs/src/queue.rs b/crates/vendor/fal-rs/src/queue.rs index 2f5d26d563..598c571ab8 100644 --- a/crates/vendor/fal-rs/src/queue.rs +++ b/crates/vendor/fal-rs/src/queue.rs @@ -22,11 +22,14 @@ pub enum Status { Completed, } +// NB(bt, 2025-06-13): Some of these fields have started to become optional. +// eg, errors: +// "missing field `source`", line: 1, column: 1019 #[derive(Debug, Serialize, Deserialize)] pub struct RequestLog { pub timestamp: String, - pub level: String, - pub source: String, + pub level: Option, // NB(bt): Now optional + pub source: Option, // NB(bt): Now optional pub message: String, }