{"record":{"id":"32279e520f4ae281","repo":"rohitg00/ai-engineering-from-scratch","slug":"title-and-body-must-be-strings","errorCode":null,"errorMessage":"title and body must be strings","messagePattern":"title and body must be strings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py","lineNumber":215,"sourceCode":"    if not isinstance(query, str) or not query:\n        raise ValueError(\"query must be a non-empty string\")\n    limit = arguments.get(\"limit\", 10)\n    if not isinstance(limit, int) or not 1 <= limit <= 50:\n        raise ValueError(\"limit must be an integer from 1 through 50\")\n    needle = query.lower()\n    hits = [\n        {\"id\": note_id, \"title\": note[\"title\"]}\n        for note_id, note in sorted(NOTES.items())\n        if needle in note[\"title\"].lower() or needle in note[\"body\"].lower()\n    ]\n    return [{\"type\": \"text\", \"text\": json.dumps(hits[:limit], sort_keys=True)}]\n\n\ndef exec_notes_create(arguments: dict[str, Any]) -> list[dict[str, Any]]:\n    title = arguments.get(\"title\")\n    body = arguments.get(\"body\")\n    if not isinstance(title, str) or not isinstance(body, str):\n        raise ValueError(\"title and body must be strings\")\n    note_id = f\"note-{uuid.uuid4().hex[:6]}\"\n    NOTES[note_id] = {\"title\": title, \"body\": body, \"tag\": str(arguments.get(\"tag\", \"\"))}\n    return [\n        {\"type\": \"text\", \"text\": f\"Created {note_id}\"},\n        {\n            \"type\": \"resource\",\n            \"resource\": {\"uri\": f\"notes://{note_id}\", \"text\": body},\n        },\n    ]\n\n\nTOOL_EXECUTORS: dict[str, Callable[[dict[str, Any]], list[dict[str, Any]]]] = {\n    \"notes_create\": exec_notes_create,\n    \"notes_list\": exec_notes_list,\n    \"notes_search\": exec_notes_search,\n}\n\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py#L197-L233","documentation":"Error \"title and body must be strings\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py:215 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"}