Skip to content

Commit d75aca5

Browse files
committed
Make header lookup case-insensitive
Normalize the requested header name before comparing so mixed-case callers still match HTTP headers case-insensitively. Constraint: Copilot review comment on PR #128 flagged _get_header as unexpectedly case-sensitive for mixed-case lookup names. Rejected: broader header abstraction | a one-line normalization preserves the current helper boundary. Confidence: high Scope-risk: narrow Tested: uv run --extra server pytest tests/unittests/server/test_error_utils.py tests/unittests/server/test_invoker.py tests/unittests/server/test_agui_protocol.py tests/unittests/integration/test_langgraph_events.py -q => 102 passed, 1 warning Tested: uv run --extra server pytest tests/unittests/integration/test_langgraph_to_agent_event.py -q => 32 passed Tested: git diff --check && uv run ruff check agentrun/server/error_utils.py tests/unittests/server/test_error_utils.py => passed Change-Id: I23e62a3b01e88c1b39f8669f89490b1c7f5e9ddf Co-developed-by: Codex <noreply@openai.com> Not-tested: full repository test suite and remote CI pending Signed-off-by: congxiao.wxx <congxiao.wxx@alibaba-inc.com>
1 parent f5d7639 commit d75aca5

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

agentrun/server/error_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ def _get_value(obj: Any, name: str) -> Optional[Any]:
131131

132132

133133
def _get_header(headers: Any, name: str) -> Optional[Any]:
134+
target = str(name).lower()
134135
if isinstance(headers, dict):
135136
for key, value in headers.items():
136-
if str(key).lower() == name:
137+
if str(key).lower() == target:
137138
return value
138139
return None
139140
get = getattr(headers, "get", None)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Tests for server error helpers."""
2+
3+
from agentrun.server.error_utils import _get_header
4+
5+
6+
def test_get_header_matches_name_case_insensitively():
7+
headers = {"x-trace-id": "trace-123"}
8+
9+
assert _get_header(headers, "X-Trace-ID") == "trace-123"

0 commit comments

Comments
 (0)