{"record":{"id":"18c1c735a13b1a35","repo":"rohitg00/ai-engineering-from-scratch","slug":"32602-18c1c7","errorCode":"-32602","errorMessage":"params must be an object","messagePattern":"params must be an object","errorType":"exception","errorClass":"ProtocolViolation","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py","lineNumber":187,"sourceCode":"            raise ProtocolViolation(\"malformed Base64 MCP header sentinel\", -32020)\n        encoded = value[len(\"=?base64?\") : -2]\n        try:\n            return base64.b64decode(encoded, validate=True).decode(\"utf-8\")\n        except (ValueError, UnicodeDecodeError) as error:\n            raise ProtocolViolation(\"malformed Base64 MCP header value\", -32020) from error\n    if value != value.strip() or any(\n        ord(character) < 0x20 or ord(character) > 0x7E for character in value\n    ):\n        raise ProtocolViolation(\"unsafe MCP header value must use the Base64 sentinel\", -32020)\n    return value\n\n\ndef validate_request(headers: dict[str, str], body: dict[str, Any], era: str) -> None:\n    if body.get(\"jsonrpc\") != \"2.0\" or not isinstance(body.get(\"method\"), str):\n        raise ProtocolViolation(\"invalid JSON-RPC request\")\n    params = body.get(\"params\", {})\n    if not isinstance(params, dict):\n        raise ProtocolViolation(\"params must be an object\", -32602)\n    wire_headers = normalized_headers(headers)\n    if era == \"legacy\":\n        if body[\"method\"] != \"initialize\" and wire_headers.get(\"mcp-protocol-version\") == MODERN_VERSION:\n            raise ProtocolViolation(\"modern metadata reached the legacy branch\", -32020)\n        return\n    if era != \"modern\":\n        raise ValueError(f\"unknown era: {era}\")\n\n    metadata = params.get(\"_meta\")\n    if not isinstance(metadata, dict):\n        raise ProtocolViolation(\"modern request is missing params._meta\", -32602)\n    protocol_version = metadata.get(PROTOCOL_VERSION_KEY)\n    capabilities = metadata.get(CLIENT_CAPABILITIES_KEY)\n    if not isinstance(protocol_version, str):\n        raise ProtocolViolation(f\"modern request is missing {PROTOCOL_VERSION_KEY}\", -32602)\n    if not isinstance(capabilities, dict):\n        raise ProtocolViolation(f\"modern request is missing {CLIENT_CAPABILITIES_KEY}\", -32021)\n","sourceCodeStart":169,"sourceCodeEnd":205,"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#L169-L205","documentation":"Error \"params must be an object\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:187 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"}