{"record":{"id":"70209b77e00ee8b8","repo":"Significant-Gravitas/AutoGPT","slug":"start-and-end-query-params-are-required-70209b","errorCode":null,"errorMessage":"start and end query params are required","messagePattern":"start and end query params are required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.py","lineNumber":131,"sourceCode":"    transaction_type: typing.Optional[CreditTransactionType] = Query(None),\n    user_id: typing.Optional[str] = Query(None),\n    include_inactive: bool = Query(\n        False,\n        description=(\n            \"Include inactive rows (e.g. abandoned Stripe checkouts). \"\n            \"Off by default so phantom rows aren't surfaced in normal exports.\"\n        ),\n    ),\n    admin_user_id: str = Security(get_user_id),\n) -> CreditTransactionsExportResponse:\n    \"\"\"Export CreditTransaction rows in [start, end].\n\n    Capped at CREDIT_EXPORT_MAX_DAYS days and CREDIT_EXPORT_MAX_ROWS rows;\n    over-cap requests fail fast with 400 so callers narrow the window\n    instead of receiving silently truncated data.\n    \"\"\"\n    if start is None or end is None:\n        raise HTTPException(\n            status_code=400, detail=\"start and end query params are required\"\n        )\n    # Coerce naive datetimes to UTC at the boundary so neither the data layer\n    # nor the response builder hits a TypeError on (end - start) when callers\n    # send mixed naive/aware shapes.\n    if start.tzinfo is None:\n        start = start.replace(tzinfo=timezone.utc)\n    if end.tzinfo is None:\n        end = end.replace(tzinfo=timezone.utc)\n    logger.info(\n        \"Admin %s exporting credit transactions [%s..%s] type=%s user=%s incl_inactive=%s\",\n        admin_user_id,\n        start.isoformat(),\n        end.isoformat(),\n        transaction_type.value if transaction_type else None,\n        user_id,\n        include_inactive,\n    )","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.py#L113-L149","documentation":"HTTP 400 from the admin credit-transaction export endpoint. Both `start` and `end` Optional datetime query params must be present; omitting either triggers this guard before the export query runs. This is deliberate fail-fast so exports never run over an unbounded range.","triggerScenarios":"GET /admin/credits/export (no query), or only one of ?start=/?end= present.","commonSituations":"CSV export button firing before the admin selects a range; frontend dropping an empty date input from the query string; copy-pasted curl missing one bound.","solutions":["Send both bounds as ISO timestamps: ?start=...&end=...","Disable the export button until both dates are chosen.","Apply a sensible default window client-side (e.g. last 30 days) when the picker is untouched."],"exampleFix":"// before\nexportCsv(`/admin/credits/export?type=${type}`)\n\n// after\nexportCsv(`/admin/credits/export?start=${startIso}&end=${endIso}&type=${type}`)","handlingStrategy":"validation","validationCode":"if (!start || !end) throw new Error('Both start and end are required');\nconst qs = new URLSearchParams({ start, end, ...filters });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the export button require both dates.","Apply a default window (e.g. last 30 days) when the picker is untouched."],"tags":["http-400","admin-api","credits","export"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}