diff --git a/core/pom.xml b/core/pom.xml
index d68324dd0..819f6f0d0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -32,7 +32,7 @@
${project.basedir}/../
64%
78%
- 79%
+ 78%
60%
77%
90%
diff --git a/core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessor.java b/core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessor.java
index ee2fc47ba..dca6f51e5 100644
--- a/core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessor.java
+++ b/core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceKeyAccessor.java
@@ -50,7 +50,7 @@ public List getServiceBindings() throws ServiceBindingAccessExce
log.debug("No service key found in environment variable {}", ENV_VAR_KEY);
return List.of();
}
- log.info(
+ log.debug(
"""
Found a service key in environment variable {}.
Using a service key is recommended for local testing only.
diff --git a/core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java b/core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java
index c1949f14f..d24b635d1 100644
--- a/core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java
+++ b/core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java
@@ -78,11 +78,11 @@ private T parseResponse(@Nonnull final ClassicHttpResponse response) throws E {
throw exceptionConstructor.apply("Response was empty.", null);
}
val content = getContent(responseEntity);
- log.debug("Parsing response from JSON response: {}", content);
+ log.trace("Deserializing JSON response to type {}: {}", responseType.getSimpleName(), content);
try {
return objectMapper.readValue(content, responseType);
} catch (final JsonProcessingException e) {
- log.error("Failed to parse the following response: {}", content);
+ log.debug("Failed to deserialize the response to type: {}", responseType.getSimpleName());
throw exceptionConstructor.apply("Failed to parse response", e);
}
}
@@ -103,10 +103,10 @@ private String getContent(@Nonnull final HttpEntity entity) {
*/
@SuppressWarnings("PMD.CloseResource")
public void buildExceptionAndThrow(@Nonnull final ClassicHttpResponse response) throws E {
+ val errorCode = response.getCode();
val exception =
exceptionConstructor.apply(
- "Request failed with status %s %s"
- .formatted(response.getCode(), response.getReasonPhrase()),
+ "Request failed with status %s %s".formatted(errorCode, response.getReasonPhrase()),
null);
val entity = response.getEntity();
if (entity == null) {
@@ -122,7 +122,8 @@ public void buildExceptionAndThrow(@Nonnull final ClassicHttpResponse response)
throw exception;
}
- log.error("The service responded with an HTTP error and the following content: {}", content);
+ log.error("The service responded with HTTP error code {}", errorCode);
+ log.trace("The service responded with HTTP error code {} and content: {}", errorCode, content);
val contentType = ContentType.parse(entity.getContentType());
if (!ContentType.APPLICATION_JSON.isSameMimeType(contentType)) {
throw exception;
diff --git a/core/src/main/java/com/sap/ai/sdk/core/common/ClientStreamingHandler.java b/core/src/main/java/com/sap/ai/sdk/core/common/ClientStreamingHandler.java
index c366b8482..f3ecf3a95 100644
--- a/core/src/main/java/com/sap/ai/sdk/core/common/ClientStreamingHandler.java
+++ b/core/src/main/java/com/sap/ai/sdk/core/common/ClientStreamingHandler.java
@@ -76,9 +76,11 @@ public Stream handleStreamingResponse(@Nonnull final ClassicHttpResponse resp
final String data = line.substring(5); // remove "data: "
try {
return objectMapper.readValue(data, responseType);
- } catch (final IOException e) { // exception message e gets lost
- log.error("Failed to parse the following response: {}", line);
- throw exceptionConstructor.apply("Failed to parse delta message: " + line, e);
+ } catch (final IOException e) {
+ final String message = e.getMessage();
+ log.error("Failed to parse the streamed response: " + message);
+ log.trace("Failed to parse the following response: {}", line);
+ throw exceptionConstructor.apply("Failed to parse delta message: " + message, e);
}
});
}
diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java
index b5c51bfc8..613239956 100644
--- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java
+++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java
@@ -40,7 +40,7 @@ T execute(
@Nonnull final Class responseType) {
try {
val json = JACKSON.writeValueAsString(payload);
- log.debug("Serialized request into JSON payload: {}", json);
+ log.trace("Serialized request into JSON payload: {}", json);
val request = new HttpPost(path);
request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));