Significant-Gravitas/AutoGPT · warning · HTTPException
str(exc)
Error message
str(exc)
What it means
HTTP 400 raised when compute_block_cost_estimates raises ValueError. The dominant causes are a window longer than ANALYTICS_MAX_DAYS or start > end. The ValueError's message is forwarded verbatim as the detail, so the response body tells you which constraint failed.
Source
Thrown at autogpt_platform/backend/backend/api/features/admin/block_cost_admin_routes.py:83
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
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
# Ceil so a [00:00:00Z, 23:59:59.999Z] window — what the frontend sends for
# an inclusive 7-day pick — reports 7, not 6 (`.days` would truncate).
window_days = math.ceil((end - start).total_seconds() / 86400)
return BlockCostEstimatesResponse(
estimates=rows,
total_rows=len(rows),
window_days=window_days,
max_window_days=ANALYTICS_MAX_DAYS,
min_samples=min_samples,
generated_at=datetime.now(timezone.utc),
)
View on GitHub (pinned to 9c8bb5550f)
Solutions
- Read the detail field — it names the exact violated constraint.
- Narrow the window to ANALYTICS_MAX_DAYS or fewer days (compare against max_window_days in any successful response).
- Swap start/end if inverted.
- For long histories, page through consecutive windows under the cap.
Example fix
// before const days = 180; // exceeds ANALYTICS_MAX_DAYS // after const MAX = lastResponse.max_window_days; // honor the advertised cap const days = Math.min(requestedDays, MAX);
Defensive patterns
Strategy: validation
Validate before calling
const maxDays = 30; // read max_window_days from a prior response when possible
const days = Math.min(maxDays, (end - start) / 86400000);
if (days < 0) throw new Error('start must be <= end'); Try / catch
try { const r = await adminBlockCostEstimates({ start, end }); } catch (e) { if (e.status === 400) { /* read e.detail: names the exact cap; narrow the window and retry once */ } } Prevention
- Cache max_window_days from responses and clamp the picker's selectable span to it.
- Always validate start <= end client-side.
- Split long analyses into consecutive capped windows.
When it happens
Trigger: Sending start/end spanning more than ANALYTICS_MAX_DAYS days (e.g. a quarter-long window against a 30/90-day cap), or an inverted range (start after end). The naive-to-UTC coercion above means tz-naive values are accepted, so timezone shape is not the trigger.
Common situations: Admin analytics UI defaulting to a 90-day window when the cap is smaller; picking a custom range that crosses the cap; DST or manual typing producing end < start.
Related errors
- start and end query params are required
- start and end query params are required
- str(exc)
- str(e)
- str(exc)
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/3ae8f22054ee005e.
Report an issue: GitHub.