diff --git a/crates/lib/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs b/crates/lib/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs index 695400f7db..3ff4ad51ed 100644 --- a/crates/lib/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs +++ b/crates/lib/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs @@ -31,6 +31,9 @@ pub async fn image_upload_from_file_with_session_auto_renew>( let err = match result { Ok(response) => return Ok((response, None)), + // We can't retry some errors. + Err(err @ SoraError::SoraUsernameNotYetCreated) => return Err(err), + // Retry all other errors. Err(err) => err, }; diff --git a/crates/lib/api_clients/openai_sora_client/src/utils/classify_general_http_error.rs b/crates/lib/api_clients/openai_sora_client/src/utils/classify_general_http_error.rs index 3ee957b49f..69912acd43 100644 --- a/crates/lib/api_clients/openai_sora_client/src/utils/classify_general_http_error.rs +++ b/crates/lib/api_clients/openai_sora_client/src/utils/classify_general_http_error.rs @@ -40,7 +40,15 @@ Message: { || message.contains("token_expired"); if cookie_expired { - return SoraError::UnauthorizedCookieOrBearerExpired + return SoraError::UnauthorizedCookieOrBearerExpired; + } + + let needs_onboarding = + message.contains("You must onboard before using this service") + || message.contains("onboarding_required"); + + if needs_onboarding { + return SoraError::SoraUsernameNotYetCreated; } let status_code = status.as_u16();