{"record":{"id":"56a4210ae284f5c1","repo":"rohitg00/ai-engineering-from-scratch","slug":"result-must-be-an-object","errorCode":null,"errorMessage":"result must be an object","messagePattern":"result 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":239,"sourceCode":"            )\n    if protocol_version != MODERN_VERSION:\n        raise ProtocolViolation(f\"unsupported protocol version: {protocol_version}\", -32022)\n\n\ndef allowed_result_types(capabilities: set[str]) -> set[str]:\n    allowed = set(CORE_RESULT_TYPES)\n    for capability in capabilities:\n        allowed.update(EXTENSION_RESULT_TYPES.get(capability, set()))\n    return allowed\n\n\ndef validate_result(\n    result: dict[str, Any],\n    era: str,\n    capabilities: set[str] | None = None,\n) -> dict[str, Any]:\n    if not isinstance(result, dict):\n        raise ProtocolViolation(\"result must be an object\")\n    preserved = dict(result)\n    result_type = result.get(\"resultType\")\n    if era == \"legacy\":\n        if result_type is None:\n            return {\"semanticType\": \"complete\", \"wire\": preserved, \"inferred\": True}\n    elif era == \"modern\":\n        if result_type is None:\n            raise ProtocolViolation(\"modern result is missing resultType\")\n    else:\n        raise ValueError(f\"unknown era: {era}\")\n\n    allowed = allowed_result_types(capabilities or set())\n    if result_type not in allowed:\n        raise ProtocolViolation(f\"unknown or unadvertised resultType: {result_type}\")\n    return {\"semanticType\": result_type, \"wire\": preserved, \"inferred\": False}\n\n\ndef validate_method_result(method: str, result: dict[str, Any]) -> None:","sourceCodeStart":221,"sourceCodeEnd":257,"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#L221-L257","documentation":"Error \"result 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:239 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"}