From cda6f10a83a6d2bcf0ec09a4ddeb812dc1f11551 Mon Sep 17 00:00:00 2001 From: Upender Kalwa Date: Fri, 20 Dec 2024 11:05:22 -0600 Subject: [PATCH] fix: value error when set-cookie header is not present --- ddtrace/contrib/internal/asgi/middleware.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ddtrace/contrib/internal/asgi/middleware.py b/ddtrace/contrib/internal/asgi/middleware.py index e32d2994a3..cc28bea89b 100644 --- a/ddtrace/contrib/internal/asgi/middleware.py +++ b/ddtrace/contrib/internal/asgi/middleware.py @@ -237,11 +237,9 @@ async def wrapped_send(message): if span and message.get("type") == "http.response.start" and "status" in message: cookies = {} - try: - cookie_key, cookie_value = response_headers.get("set-cookie", "").split("=", maxsplit=1) + cookie_key, _, cookie_value = response_headers.get("set-cookie", "").partition("=") + if cookie_key and cookie_value: cookies[cookie_key] = cookie_value - except Exception: - log.debug("failed to extract response cookies", exc_info=True) status_code = message["status"] trace_utils.set_http_meta(