jamiepine/voicebox · error · ValueError

`limit` must be between 1 and 200.

Error message

`limit` must be between 1 and 200.

What it means

Raised by voicebox.list_captures when the limit argument is outside the inclusive range [1, 200]. The check is `not (1 <= limit <= 200)`. Default is 20.

Source

Thrown at backend/mcp_server/tools.py:184

            tmp.write(raw)
            tmp_path = Path(tmp.name)
        try:
            return await _transcribe_file(tmp_path, language, model)
        finally:
            tmp_path.unlink(missing_ok=True)

    @mcp.tool(
        name="voicebox.list_captures",
        description=(
            "List recent voice captures (dictations, recordings, uploads) "
            "with their transcripts. Most-recent first."
        ),
    )
    async def voicebox_list_captures(
        limit: int = 20, offset: int = 0
    ) -> dict[str, Any]:
        if not (1 <= limit <= 200):
            raise ValueError("`limit` must be between 1 and 200.")
        if offset < 0:
            raise ValueError("`offset` must be >= 0.")
        db = next(get_db())
        try:
            items, total = captures_service.list_captures(
                db, limit=limit, offset=offset
            )
            return {
                "captures": [
                    item.model_dump(mode="json") for item in items
                ],
                "total": total,
            }
        finally:
            db.close()

    @mcp.tool(
        name="voicebox.list_profiles",

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Pass an integer between 1 and 200 (inclusive).
  2. If you need more than 200 rows, page with offset (e.g. limit=200, offset=0, then offset=200).
  3. Clamp client-side before calling: limit = max(1, min(200, requested)).

Example fix

// before
voicebox.list_captures(limit=0)
// after
voicebox.list_captures(limit=20)
Defensive patterns

Strategy: validation

Validate before calling

if not isinstance(limit, int) or not (1 <= limit <= 200):
    limit = max(1, min(200, int(limit) if isinstance(limit, int) else 20))
await voicebox.list_captures(limit=limit, offset=offset)

Type guard

def is_valid_list_limit(value: int) -> bool:
    return isinstance(value, int) and 1 <= value <= 200

Try / catch

try:
    await voicebox.list_captures(limit=limit, offset=offset)
except ValueError as exc:
    if "limit" in str(exc):
        await voicebox.list_captures(limit=max(1, min(200, limit or 20)), offset=offset)
    else:
        raise

Prevention

When it happens

Trigger: Calling voicebox.list_captures(limit=0), limit=-1, limit=201, or a very large 'give me everything' value like limit=10000.

Common situations: Pagination UI sending limit=0 on an empty state; a 'fetch all' shortcut that sets a huge limit; off-by-one from a component that uses limit as 'last index'.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/805d44ea3a1b050c. Report an issue: GitHub.