rohitg00/ai-engineering-from-scratch · error · ProtocolViolation
result must be an object
Error message
result must be an object
What it means
Error "result must be an object" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:239
)
if protocol_version != MODERN_VERSION:
raise ProtocolViolation(f"unsupported protocol version: {protocol_version}", -32022)
def allowed_result_types(capabilities: set[str]) -> set[str]:
allowed = set(CORE_RESULT_TYPES)
for capability in capabilities:
allowed.update(EXTENSION_RESULT_TYPES.get(capability, set()))
return allowed
def validate_result(
result: dict[str, Any],
era: str,
capabilities: set[str] | None = None,
) -> dict[str, Any]:
if not isinstance(result, dict):
raise ProtocolViolation("result must be an object")
preserved = dict(result)
result_type = result.get("resultType")
if era == "legacy":
if result_type is None:
return {"semanticType": "complete", "wire": preserved, "inferred": True}
elif era == "modern":
if result_type is None:
raise ProtocolViolation("modern result is missing resultType")
else:
raise ValueError(f"unknown era: {era}")
allowed = allowed_result_types(capabilities or set())
if result_type not in allowed:
raise ProtocolViolation(f"unknown or unadvertised resultType: {result_type}")
return {"semanticType": result_type, "wire": preserved, "inferred": False}
def validate_method_result(method: str, result: dict[str, Any]) -> None: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:239 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/56a4210ae284f5c1.
Report an issue: GitHub.