{"record":{"id":"8fe874c08eb3d185","repo":"rohitg00/ai-engineering-from-scratch","slug":"32020-8fe874","errorCode":"-32020","errorMessage":"conflicting duplicate HTTP header: {name}","messagePattern":"conflicting duplicate HTTP header: (.+?)","errorType":"exception","errorClass":"ProtocolViolation","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py","lineNumber":150,"sourceCode":"\n\ndef routing_name(body: dict[str, Any]) -> str | None:\n    params = body.get(\"params\", {})\n    if not isinstance(params, dict):\n        return None\n    for key in (\"name\", \"taskId\", \"uri\"):\n        value = params.get(key)\n        if isinstance(value, str):\n            return value\n    return None\n\n\ndef normalized_headers(headers: dict[str, str]) -> dict[str, str]:\n    normalized: dict[str, str] = {}\n    for name, value in headers.items():\n        key = name.lower()\n        if key in normalized and normalized[key] != value:\n            raise ProtocolViolation(f\"conflicting duplicate HTTP header: {name}\", -32020)\n        normalized[key] = value\n    return normalized\n\n\ndef encode_header_value(value: str) -> str:\n    safe = all(0x20 <= ord(character) <= 0x7E for character in value)\n    sentinel = value.startswith(\"=?base64?\") and value.endswith(\"?=\")\n    if safe and value == value.strip() and not sentinel:\n        return value\n    encoded = base64.b64encode(value.encode(\"utf-8\")).decode(\"ascii\")\n    return f\"=?base64?{encoded}?=\"\n\n\ndef decode_header_value(value: str) -> str:\n    starts = value.startswith(\"=?base64?\")\n    ends = value.endswith(\"?=\")\n    if starts or ends:\n        if not (starts and ends):","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py#L132-L168","documentation":"Error \"conflicting duplicate HTTP header: {name}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}