Significant-Gravitas/AutoGPT · warning · HTTPException
str(exc)
Error message
str(exc)
What it means
HTTP 400 from the credit-transaction export endpoint; admin_export_user_history raised ValueError and its message becomes the response detail. By design the export is capped at CREDIT_EXPORT_MAX_DAYS days and CREDIT_EXPORT_MAX_ROWS rows, and any violation (window too long, or a constraint on the filters) surfaces here as a 400 instead of silently truncated data.
Source
Thrown at autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.py:159
logger.info(
"Admin %s exporting credit transactions [%s..%s] type=%s user=%s incl_inactive=%s",
admin_user_id,
start.isoformat(),
end.isoformat(),
transaction_type.value if transaction_type else None,
user_id,
include_inactive,
)
try:
history = await admin_export_user_history(
start=start,
end=end,
transaction_type=transaction_type,
user_id=user_id,
include_inactive=include_inactive,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
return CreditTransactionsExportResponse(
transactions=history,
total_rows=len(history),
window_days=(end - start).days,
max_window_days=CREDIT_EXPORT_MAX_DAYS,
)
class CopilotUsageExportResponse(BaseModel):
rows: list[CopilotWeeklyUsageRow]
total_rows: int
window_days: int
max_window_days: int
@router.get(
"/copilot-usage/export",
response_model=CopilotUsageExportResponse,View on GitHub (pinned to 9c8bb5550f)
Solutions
- Read the detail message to identify which cap was breached.
- Split the export into consecutive windows of at most CREDIT_EXPORT_MAX_DAYS days (the response reports window_days and max_window_days).
- Add user_id or transaction_type filters to keep row count under CREDIT_EXPORT_MAX_ROWS.
- Verify start <= end.
Example fix
# before: one 180-day request curl '/admin/credits/export?start=2026-01-01T00:00:00Z&end=2026-06-30T00:00:00Z' # after: two capped windows curl '/admin/credits/export?start=2026-01-01T00:00:00Z&end=2026-03-31T23:59:59Z' curl '/admin/credits/export?start=2026-04-01T00:00:00Z&end=2026-06-30T23:59:59Z'
Defensive patterns
Strategy: validation
Validate before calling
const MAX_DAYS = 90; // keep in sync with CREDIT_EXPORT_MAX_DAYS
function splitWindows(start: Date, end: Date): [Date, Date][] { /* consecutive <=MAX_DAYS slices */ } Try / catch
try { await exportCredits({ start, end }); } catch (e) { if (e.status === 400 && /days/.test(e.detail)) { for (const [s, t] of splitWindows(start, end)) await exportCredits({ start: s, end: t }); } } Prevention
- Chunk exports into windows under the advertised cap before requesting.
- Filter by transaction_type/user_id to stay under the row cap.
- Read window_days/max_window_days from responses to self-calibrate.
When it happens
Trigger: Requesting a window longer than CREDIT_EXPORT_MAX_DAYS; start after end; or an invalid combination of transaction_type/user_id filters that the data layer rejects.
Common situations: Finance wanting a full-quarter export when the cap is 90 days; admins paginating by widening the range instead of narrowing it; typo'd transaction_type value.
Related errors
- start and end query params are required
- start and end query params are required
- str(exc)
- str(exc)
- Either user_id or email query parameter is required.
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/cb7898c81a6154cc.
Report an issue: GitHub.