From bdf3170648999e2f7bc307736edbf589fb2a011f Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 1 Apr 2026 02:19:31 -0400 Subject: [PATCH] invalid api key --- .../src/webhook_api/parse_webhook_inner_payload.rs | 10 +++++----- .../src/webhook_api/payload/webhook_error_type.rs | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/api_clients/fal_client/src/webhook_api/parse_webhook_inner_payload.rs b/crates/api_clients/fal_client/src/webhook_api/parse_webhook_inner_payload.rs index 9cf3553e5a..85554dab35 100644 --- a/crates/api_clients/fal_client/src/webhook_api/parse_webhook_inner_payload.rs +++ b/crates/api_clients/fal_client/src/webhook_api/parse_webhook_inner_payload.rs @@ -1,8 +1,8 @@ use serde_json::Value; -use crate::webhook_api::payload::webhook_inner_payload::{WebhookInnerPayload, SuccessData, ErrorData, PayloadErrorData}; -use crate::webhook_api::payload::webhook_payload::{WebhookPayload, WebhookStatus}; use crate::webhook_api::payload::webhook_error_type::WebhookErrorType; +use crate::webhook_api::payload::webhook_inner_payload::{ErrorData, PayloadErrorData, SuccessData, WebhookInnerPayload}; +use crate::webhook_api::payload::webhook_payload::{WebhookPayload, WebhookStatus}; /// Parse the inner payload of a FAL webhook into one of three cases. /// @@ -12,7 +12,7 @@ use crate::webhook_api::payload::webhook_error_type::WebhookErrorType; pub fn parse_webhook_inner_payload(webhook: &WebhookPayload) -> WebhookInnerPayload { match webhook.status { WebhookStatus::Error => { - let (message, error_type) = extract_first_detail(&webhook.payload); + let (message, error_type) = extract_error_first_detail(&webhook.payload); WebhookInnerPayload::Error(ErrorData { message, @@ -37,7 +37,7 @@ pub fn parse_webhook_inner_payload(webhook: &WebhookPayload) -> WebhookInnerPayl } /// Extract the first `msg` and `type` from `payload.detail[]`. -fn extract_first_detail(payload: &Option) -> (Option, Option) { +fn extract_error_first_detail(payload: &Option) -> (Option, Option) { let payload = match payload { Some(p) => p, None => return (None, None), @@ -104,7 +104,7 @@ mod tests { WebhookInnerPayload::Error(data) => { assert_eq!( data.error_type, - Some(WebhookErrorType::Unknown("invalid_api_key".to_string())), + Some(WebhookErrorType::InvalidApiKey), ); assert_eq!( data.message.as_deref(), diff --git a/crates/api_clients/fal_client/src/webhook_api/payload/webhook_error_type.rs b/crates/api_clients/fal_client/src/webhook_api/payload/webhook_error_type.rs index f78f449271..29c831a81c 100644 --- a/crates/api_clients/fal_client/src/webhook_api/payload/webhook_error_type.rs +++ b/crates/api_clients/fal_client/src/webhook_api/payload/webhook_error_type.rs @@ -31,6 +31,7 @@ pub enum WebhookErrorType { InvalidArchive, ArchiveFileCountBelowMinimum, ArchiveFileCountExceedsMaximum, + InvalidApiKey, /// Catch-all for unrecognized error types from FAL. #[serde(untagged)] @@ -75,6 +76,7 @@ mod tests { ("\"invalid_archive\"", WebhookErrorType::InvalidArchive), ("\"archive_file_count_below_minimum\"", WebhookErrorType::ArchiveFileCountBelowMinimum), ("\"archive_file_count_exceeds_maximum\"", WebhookErrorType::ArchiveFileCountExceedsMaximum), + ("\"invalid_api_key\"", WebhookErrorType::InvalidApiKey), ]; for (json, expected) in cases {