{"record":{"id":"ccdcc833ced2a43a","repo":"Significant-Gravitas/AutoGPT","slug":"start-and-end-query-params-are-required","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/block_cost_admin_routes.py","lineNumber":62,"sourceCode":"    end: typing.Optional[datetime] = Query(\n        None, description=\"ISO timestamp (inclusive)\"\n    ),\n    min_samples: int = Query(\n        10, ge=1, description=\"Minimum executions per block to include\"\n    ),\n    admin_user_id: str = Security(get_user_id),\n) -> BlockCostEstimatesResponse:\n    \"\"\"Aggregate per-block average credits-per-execution over [start, end].\n\n    Capped at ANALYTICS_MAX_DAYS days. Returns only blocks whose current cost\n    type is dynamic (SECOND/ITEMS/COST_USD) — static-cost blocks already\n    charge correctly pre-flight and don't need an estimate override. TOKENS\n    is excluded because `compute_token_credits` already supplies a per-model\n    floor at pre-flight; a per-block historical mean would lose that\n    granularity.\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    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\n    logger.info(\n        \"Admin %s aggregating block cost estimates [%s..%s] min_samples=%s\",\n        admin_user_id,\n        start.isoformat(),\n        end.isoformat(),\n        min_samples,\n    )\n\n    try:\n        rows = await compute_block_cost_estimates(\n            start=start, end=end, min_samples=min_samples","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/admin/block_cost_admin_routes.py#L44-L80","documentation":"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.","triggerScenarios":"GET /admin/.../block-cost-estimates without ?start=...&end=..., or with only one of the two (e.g. ?start=2026-01-01T00:00:00Z).","commonSituations":"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.","solutions":["Always send both ISO-8601 timestamps: ?start=2026-01-01T00:00:00Z&end=2026-01-08T00:00:00Z.","Gate the admin fetch until the picker has both values.","Default missing bounds client-side (end = now, start = now - 7d) rather than sending a partial range."],"exampleFix":"// before\nfetch(`/admin/block-cost-estimates?start=${start ?? ''}`)\n\n// after\nif (!start || !end) return;\nfetch(`/admin/block-cost-estimates?start=${start}&end=${end}`)","handlingStrategy":"validation","validationCode":"if (!start || !end) { /* don't fetch yet */ } else { fetch(`...?start=${start}&end=${end}`); }","typeGuard":"function hasFullRange(s?: string, e?: string): s is string & e is string { return Boolean(s && e); }","tryCatchPattern":null,"preventionTips":["Gate admin analytics requests on a complete date range.","Default missing bounds client-side (end=now, start=now-7d) instead of sending partial ranges."],"tags":["http-400","admin-api","query-params","validation"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}