Fix databricks streaming errors (#4506)

This commit is contained in:
David Katz
2025-09-04 10:32:12 -04:00
committed by GitHub
parent 6552d89d6d
commit 422bb77c38
2 changed files with 29 additions and 12 deletions
+9 -6
View File
@@ -16,7 +16,9 @@ use super::errors::ProviderError;
use super::formats::databricks::{create_request, response_to_message};
use super::oauth;
use super::retry::ProviderRetry;
use super::utils::{get_model, handle_response_openai_compat, ImageFormat};
use super::utils::{
get_model, handle_response_openai_compat, map_http_error_to_provider_error, ImageFormat,
};
use crate::config::ConfigError;
use crate::conversation::message::Message;
use crate::impl_provider_default;
@@ -326,11 +328,12 @@ impl Provider for DatabricksProvider {
.with_retry(|| async {
let resp = self.api_client.response_post(&path, &payload).await?;
if !resp.status().is_success() {
return Err(ProviderError::RequestFailed(format!(
"HTTP {}: {}",
resp.status(),
resp.text().await.unwrap_or_default()
)));
let status = resp.status();
let error_text = resp.text().await.unwrap_or_default();
// Parse as JSON if possible to pass to map_http_error_to_provider_error
let json_payload = serde_json::from_str::<Value>(&error_text).ok();
return Err(map_http_error_to_provider_error(status, json_payload));
}
Ok(resp)
})