{"record":{"id":"dd0d1a5cd3464abe","repo":"rohitg00/ai-engineering-from-scratch","slug":"peer-name-bounded-legacy-probe-returned-no-resu","errorCode":null,"errorMessage":"{peer.name}: bounded legacy probe returned no result","messagePattern":"(.+?): bounded legacy probe returned no result","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/08-building-an-mcp-client/code/main.py","lineNumber":373,"sourceCode":"            raise RuntimeError(\n                f\"{peer.name}: {trigger}; legacy compatibility is not allowlisted\"\n            )\n        request_id = self._new_id()\n        initialize = legacy_request(\n            request_id,\n            \"initialize\",\n            {\n                \"protocolVersion\": self.supported_legacy[0],\n                \"capabilities\": self.client_capabilities.copy(),\n                \"clientInfo\": CLIENT_INFO.copy(),\n            },\n        )\n        try:\n            response = self._send(peer, initialize, self.legacy_probe_timeout_ms)\n        except (TimeoutError, ConnectionError) as exc:\n            raise RuntimeError(f\"{peer.name}: bounded legacy probe failed closed\") from exc\n        if not isinstance(response, dict):\n            raise RuntimeError(f\"{peer.name}: bounded legacy probe returned no result\")\n        kind, payload = decode_rpc_response(response, request_id)\n        if kind != \"result\":\n            raise RuntimeError(f\"{peer.name}: legacy initialize returned an error\")\n        result = payload\n        version = result.get(\"protocolVersion\")\n        capabilities = result.get(\"capabilities\")\n        server_info = result.get(\"serverInfo\")\n        valid_server_info = (\n            isinstance(server_info, dict)\n            and isinstance(server_info.get(\"name\"), str)\n            and bool(server_info[\"name\"])\n            and isinstance(server_info.get(\"version\"), str)\n            and bool(server_info[\"version\"])\n        )\n        if version not in self.supported_legacy:\n            raise RuntimeError(f\"{peer.name}: unsupported legacy protocol revision\")\n        if not isinstance(capabilities, dict) or not valid_server_info:\n            raise RuntimeError(f\"{peer.name}: malformed legacy initialize result\")","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/08-building-an-mcp-client/code/main.py#L355-L391","documentation":"The legacy initialize probe completed but _send returned something that is not a dict (None, a string, a list, etc.), so there is no JSON-RPC message to decode. The client refuses to guess and aborts the legacy handshake for that peer.","triggerScenarios":"_probe_legacy gets a response from self._send(peer, initialize, ...) where isinstance(response, dict) is False — e.g. the transport returns None on close or a raw string payload.","commonSituations":"Buggy transport shim that returns the raw wire text instead of parsed JSON; server closing the connection mid-handshake so the reader yields None; a mock/fake transport in tests returning the wrong shape.","solutions":["Inspect what the transport actually returned for the initialize call","Fix the transport to parse frames into dicts before returning","Check the server logs for a crash during initialize","In tests, make the fake transport return a JSON-RPC response dict"],"exampleFix":"// before\ndef fake_send(peer, msg, timeout):\n    return json.dumps({\"jsonrpc\": \"2.0\", \"id\": msg[\"id\"], \"result\": {}})\n\n// after\ndef fake_send(peer, msg, timeout):\n    return {\"jsonrpc\": \"2.0\", \"id\": msg[\"id\"], \"result\": {}}","handlingStrategy":"type-guard","validationCode":"response = transport.peek_response(peer)\nif not isinstance(response, dict):\n    fix_transport_parse()  # before running connect_all","typeGuard":"def is_rpc_message(value) -> bool:\n    return isinstance(value, dict) and (\"result\" in value or \"error\" in value)","tryCatchPattern":"try:\n    client.connect_all()\nexcept RuntimeError as e:\n    if \"returned no result\" in str(e):\n        log_transport_dump(peer)","preventionTips":["Unit-test transports to always return parsed dicts","Add transport-level schema checks in CI"],"tags":["mcp","transport","response-shape","legacy"],"backgroundTag":"malformed-rpc-response","analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}