rohitg00/ai-engineering-from-scratch · error · ValueError
limit must be an integer from 1 through 50
Error message
limit must be an integer from 1 through 50
What it means
Error "limit must be an integer from 1 through 50" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py:201
def exec_notes_list(arguments: dict[str, Any]) -> list[dict[str, str]]:
tag = arguments.get("tag")
items = [
{"id": note_id, "title": note["title"], "tag": note.get("tag", "")}
for note_id, note in sorted(NOTES.items())
if not tag or note.get("tag") == tag
]
return [{"type": "text", "text": json.dumps(items, sort_keys=True)}]
def exec_notes_search(arguments: dict[str, Any]) -> list[dict[str, str]]:
query = arguments.get("query")
if not isinstance(query, str) or not query:
raise ValueError("query must be a non-empty string")
limit = arguments.get("limit", 10)
if not isinstance(limit, int) or not 1 <= limit <= 50:
raise ValueError("limit must be an integer from 1 through 50")
needle = query.lower()
hits = [
{"id": note_id, "title": note["title"]}
for note_id, note in sorted(NOTES.items())
if needle in note["title"].lower() or needle in note["body"].lower()
]
return [{"type": "text", "text": json.dumps(hits[:limit], sort_keys=True)}]
def exec_notes_create(arguments: dict[str, Any]) -> list[dict[str, Any]]:
title = arguments.get("title")
body = arguments.get("body")
if not isinstance(title, str) or not isinstance(body, str):
raise ValueError("title and body must be strings")
note_id = f"note-{uuid.uuid4().hex[:6]}"
NOTES[note_id] = {"title": title, "body": body, "tag": str(arguments.get("tag", ""))}
return [
{"type": "text", "text": f"Created {note_id}"},View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py:201 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/b5afe3b3cbb09966.
Report an issue: GitHub.