rohitg00/ai-engineering-from-scratch · error · ProtocolViolation
-32020
-32020
Error message
conflicting duplicate HTTP header: {name} What it means
Error "conflicting duplicate HTTP header: {name}" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:150
def routing_name(body: dict[str, Any]) -> str | None:
params = body.get("params", {})
if not isinstance(params, dict):
return None
for key in ("name", "taskId", "uri"):
value = params.get(key)
if isinstance(value, str):
return value
return None
def normalized_headers(headers: dict[str, str]) -> dict[str, str]:
normalized: dict[str, str] = {}
for name, value in headers.items():
key = name.lower()
if key in normalized and normalized[key] != value:
raise ProtocolViolation(f"conflicting duplicate HTTP header: {name}", -32020)
normalized[key] = value
return normalized
def encode_header_value(value: str) -> str:
safe = all(0x20 <= ord(character) <= 0x7E for character in value)
sentinel = value.startswith("=?base64?") and value.endswith("?=")
if safe and value == value.strip() and not sentinel:
return value
encoded = base64.b64encode(value.encode("utf-8")).decode("ascii")
return f"=?base64?{encoded}?="
def decode_header_value(value: str) -> str:
starts = value.startswith("=?base64?")
ends = value.endswith("?=")
if starts or ends:
if not (starts and ends):View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:150 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/8fe874c08eb3d185.
Report an issue: GitHub.