Fix potential header issue

This commit is contained in:
Ashton Sidhu 2026-03-19 10:24:00 -04:00
parent fcb16d91af
commit 7fd02e7d56

View file

@ -348,7 +348,10 @@ class HiddenlayerGuardrailV2(CustomGuardrail):
# put our roundtrip id in the header to the model so we get it on the way back from the model
if "hl-roundtrip-id" not in headers:
request_data["proxy_server_request"]["headers"]["hl-roundtrip-id"] = str(uuid4())
proxy_req = request_data.get("proxy_server_request")
if proxy_req is not None and "headers" in proxy_req:
proxy_req["headers"]["hl-roundtrip-id"] = str(uuid4())
headers["hl-roundtrip-id"] = proxy_req["headers"]["hl-roundtrip-id"]
hl_headers = {h.lower():v for h,v in headers.items() if h.lower().startswith("hl-")}