unclecode/crawl4ai · warning · HTTPException

Invalid window: {window}. Only '5m' is currently supported

Error message

Invalid window: {window}. Only '5m' is currently supported

What it means

An explicit 400 validation error raised by GET /monitor/timeline when the window query parameter is not exactly '5m'. The timeline feature currently implements only a single fixed 5-minute window, so the check is a strict equality gate (window != '5m') rather than a parsed duration - any other value, including longer/shorter windows, is rejected.

Source

Thrown at deploy/docker/monitor_routes.py:111

        return monitor.get_endpoint_stats_summary()
    except Exception as e:
        logger.error(f"Error getting endpoint stats: {e}")
        raise HTTPException(500, str(e))


@router.get("/timeline")
async def get_timeline(metric: str = "memory", window: str = "5m"):
    """Get timeline data for charts.

    Args:
        metric: 'memory', 'requests', or 'browsers'
        window: Time window (only '5m' supported for now)
    """
    # Input validation
    if metric not in ["memory", "requests", "browsers"]:
        raise HTTPException(400, f"Invalid metric: {metric}. Must be one of: memory, requests, browsers")
    if window != "5m":
        raise HTTPException(400, f"Invalid window: {window}. Only '5m' is currently supported")

    try:
        monitor = get_monitor()
        return monitor.get_timeline_data(metric, window)
    except Exception as e:
        logger.error(f"Error getting timeline: {e}")
        raise HTTPException(500, str(e))


@router.get("/logs/janitor")
async def get_janitor_log(limit: int = 100):
    """Get recent janitor cleanup events."""
    # Input validation
    if limit < 1 or limit > 1000:
        raise HTTPException(400, f"Invalid limit: {limit}. Must be between 1 and 1000")

    try:
        monitor = get_monitor()

View on GitHub (pinned to 7e80152142)

Solutions

  1. Send exactly window=5m (the default) - it is the only supported value.
  2. Pin the client's time-range selector to a single 'Last 5 minutes' option until the server supports more windows.
  3. To support other windows, extend monitor.get_timeline_data() to accept parsed durations, then relax the equality check to an allow-list.

Example fix

# before
const url = `/monitor/timeline?metric=memory&window=${range}`; // range = '1h'

# after
const url = `/monitor/timeline?metric=memory&window=5m`;
Defensive patterns

Strategy: validation

Validate before calling

def valid_window(w: str) -> bool:
    return w == '5m'

window = w if valid_window(w) else '5m'
url = f"/monitor/timeline?window={window}"

Type guard

from typing import Literal

Window = Literal['5m']

def is_window(v: str) -> TypeGuard[Window]:
    return v == '5m'

Try / catch

try:
    resp = get(f"{base}/monitor/timeline?window={window}")
except HTTPError as e:
    if e.response.status_code == 400:
        window = '5m'  # only supported value; retry once with it
        resp = get(f"{base}/monitor/timeline?window=5m")
    else:
        raise

Prevention

When it happens

Trigger: Calling GET /monitor/timeline?window=1m, ?window=15m, ?window=300s, or omitting a custom default when constructing the URL manually; dashboards that send a user-selected time range other than 5 minutes.

Common situations: UI time-range selector offers multiple windows but the backend only supports one; API consumers assuming ISO-8601 durations or second-based values; default value differs between client (e.g. '1h') and server ('5m').

Related errors


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/7fcd21d96a9cae2d. Report an issue: GitHub.