diff --git a/openai/openai-common/runtime/src/main/java/io/quarkiverse/langchain4j/openai/OpenAiRestApi.java b/openai/openai-common/runtime/src/main/java/io/quarkiverse/langchain4j/openai/OpenAiRestApi.java index 84e26966d..2f3a99199 100644 --- a/openai/openai-common/runtime/src/main/java/io/quarkiverse/langchain4j/openai/OpenAiRestApi.java +++ b/openai/openai-common/runtime/src/main/java/io/quarkiverse/langchain4j/openai/OpenAiRestApi.java @@ -373,6 +373,8 @@ private String inOneLine(MultiMap headers) { headerValue = maskAuthorizationHeaderValue(headerValue); } else if (headerKey.equals("api-key")) { headerValue = maskApiKeyHeaderValue(headerValue); + } else if (headerKey.equals("Set-Cookie")) { + headerValue = maskCookieHeaderValue(headerValue); } return String.format("[%s: %s]", headerKey, headerValue); }) @@ -408,6 +410,19 @@ private static String maskApiKeyHeaderValue(String apiKeyHeaderValue) { return "Failed to mask the API key."; } } + + private static String maskCookieHeaderValue(String cookieHeaderValue) { + try { + if (cookieHeaderValue.length() <= 4) { + return cookieHeaderValue; + } + return cookieHeaderValue.substring(0, 2) + + "..." + + cookieHeaderValue.substring(cookieHeaderValue.length() - 2); + } catch (Exception e) { + return "Failed to mask the cookie value."; + } + } } class ApiMetadata {