{"record":{"id":"b350d5f0d69fb371","repo":"rohitg00/ai-engineering-from-scratch","slug":"query-must-be-a-non-empty-string","errorCode":null,"errorMessage":"query must be a non-empty string","messagePattern":"query must be a non-empty string","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py","lineNumber":198,"sourceCode":"        or not isinstance(client_info.get(\"version\"), str)\n    ):\n        raise RpcProblem(-32602, f\"{CLIENT_INFO_KEY} is malformed\")\n\n\ndef exec_notes_list(arguments: dict[str, Any]) -> list[dict[str, str]]:\n    tag = arguments.get(\"tag\")\n    items = [\n        {\"id\": note_id, \"title\": note[\"title\"], \"tag\": note.get(\"tag\", \"\")}\n        for note_id, note in sorted(NOTES.items())\n        if not tag or note.get(\"tag\") == tag\n    ]\n    return [{\"type\": \"text\", \"text\": json.dumps(items, sort_keys=True)}]\n\n\ndef exec_notes_search(arguments: dict[str, Any]) -> list[dict[str, str]]:\n    query = arguments.get(\"query\")\n    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]}\"","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py#L180-L216","documentation":"Error \"query must be a non-empty string\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py:198 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"}