rohitg00/ai-engineering-from-scratch · error · ValueError
record root must be an object
Error message
record root must be an object
What it means
JSON-RPC request validation (error code -32602, invalid params): validateRequest found msg.params is not a plain object — it is missing, an array, or a primitive. The dispatcher reads named fields off params, so the request cannot be routed to a tool and is rejected before execution.
Solutions
- Send params as a JSON object, e.g. {"name": "...", "arguments": {}}
- Default missing params to {} at the transport edge if your method allows it
- Return the -32602 error to the client with the received params echoed for debugging
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at certifications/claude/lessons/01-claude-product-and-model-landscape/code/main.py:209 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/3b52ae3745b0bf7f.
Report an issue: GitHub.
Appendix: source
Thrown at certifications/claude/lessons/01-claude-product-and-model-landscape/code/main.py:209
return isinstance(value, str) and value.startswith(OFFICIAL_DOC_PREFIXES)
def _nonempty_strings(value: Any) -> bool:
return isinstance(value, list) and bool(value) and all(isinstance(item, str) and item.strip() for item in value)
def _iso_date(value: Any) -> bool:
try:
date.fromisoformat(value)
return isinstance(value, str)
except (TypeError, ValueError):
return False
def load_record(path: Path) -> dict[str, Any]:
value = json.loads(path.read_text(encoding="utf-8"))
if not isinstance(value, dict):
raise ValueError("record root must be an object")
return value
if __name__ == "__main__":
path = Path(__file__).parents[1] / "outputs" / "product-selection-record.json"
record = load_record(path)
print(json.dumps({"valid": not validate_record(record), "recommendation": recommend(record)}, indent=2))
View on GitHub (pinned to 39ea8a1c6d)