Significant-Gravitas/AutoGPT · warning · HTTPException

start and end query params are required

Error message

start and end query params are required

What it means

HTTP 400 from the admin endpoint that aggregates per-block average credits-per-execution (block_cost_admin_routes). Both `start` and `end` are Optional datetime Query params; if either is omitted the route raises immediately. The params are Optional precisely so a missing value produces this 400 instead of FastAPI's generic 422, letting the route control the message.

Source

Thrown at autogpt_platform/backend/backend/api/features/admin/block_cost_admin_routes.py:62

    end: typing.Optional[datetime] = Query(
        None, description="ISO timestamp (inclusive)"
    ),
    min_samples: int = Query(
        10, ge=1, description="Minimum executions per block to include"
    ),
    admin_user_id: str = Security(get_user_id),
) -> BlockCostEstimatesResponse:
    """Aggregate per-block average credits-per-execution over [start, end].

    Capped at ANALYTICS_MAX_DAYS days. Returns only blocks whose current cost
    type is dynamic (SECOND/ITEMS/COST_USD) — static-cost blocks already
    charge correctly pre-flight and don't need an estimate override. TOKENS
    is excluded because `compute_token_credits` already supplies a per-model
    floor at pre-flight; a per-block historical mean would lose that
    granularity.
    """
    if start is None or end is None:
        raise HTTPException(
            status_code=400, detail="start and end query params are required"
        )
    if start.tzinfo is None:
        start = start.replace(tzinfo=timezone.utc)
    if end.tzinfo is None:
        end = end.replace(tzinfo=timezone.utc)

    logger.info(
        "Admin %s aggregating block cost estimates [%s..%s] min_samples=%s",
        admin_user_id,
        start.isoformat(),
        end.isoformat(),
        min_samples,
    )

    try:
        rows = await compute_block_cost_estimates(
            start=start, end=end, min_samples=min_samples

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Always send both ISO-8601 timestamps: ?start=2026-01-01T00:00:00Z&end=2026-01-08T00:00:00Z.
  2. Gate the admin fetch until the picker has both values.
  3. Default missing bounds client-side (end = now, start = now - 7d) rather than sending a partial range.

Example fix

// before
fetch(`/admin/block-cost-estimates?start=${start ?? ''}`)

// after
if (!start || !end) return;
fetch(`/admin/block-cost-estimates?start=${start}&end=${end}`)
Defensive patterns

Strategy: validation

Validate before calling

if (!start || !end) { /* don't fetch yet */ } else { fetch(`...?start=${start}&end=${end}`); }

Type guard

function hasFullRange(s?: string, e?: string): s is string & e is string { return Boolean(s && e); }

Prevention

When it happens

Trigger: GET /admin/.../block-cost-estimates without ?start=...&end=..., or with only one of the two (e.g. ?start=2026-01-01T00:00:00Z).

Common situations: Date-range picker not yet submitted while a fetch fires on mount; frontend omitting an empty end date instead of falling back to 'now'; hand-crafted curl requests forgetting one bound.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/ccdcc833ced2a43a. Report an issue: GitHub.