{"record":{"id":"0475238207ccb2c5","repo":"BerriAI/litellm","slug":"start-time-utc-and-end-time-utc-must-be-provided-t","errorCode":null,"errorMessage":"start_time_utc and end_time_utc must be provided together","messagePattern":"start_time_utc and end_time_utc must be provided together","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/focus_logger.py","lineNumber":92,"sourceCode":"            )\n        return self._engine\n\n    async def export_usage_data(\n        self,\n        *,\n        limit: int | None = None,\n        start_time_utc: datetime | None = None,\n        end_time_utc: datetime | None = None,\n    ) -> None:\n        \"\"\"Public hook to trigger export immediately.\n\n        When called without time bounds (manual /vantage/export with no\n        start/end), exports **all** available data instead of the last\n        scheduled window.  The hourly/daily window only applies to\n        automatic scheduler runs.\n        \"\"\"\n        if bool(start_time_utc) ^ bool(end_time_utc):\n            raise ValueError(\"start_time_utc and end_time_utc must be provided together\")\n\n        if start_time_utc and end_time_utc:\n            window: Final = FocusTimeWindow(\n                start_time=start_time_utc,\n                end_time=end_time_utc,\n                frequency=self.frequency,\n            )\n            await self._export_window(window=window, limit=limit)\n        else:\n            # No time bounds → export all available data\n            await self._export_all(limit=limit)\n\n    async def dry_run_export_usage_data(self, limit: int | None = DEFAULT_DRY_RUN_LIMIT) -> dict[str, Any]:\n        \"\"\"Return transformed data without uploading.\"\"\"\n        engine: Final = self._ensure_engine()\n        return await engine.dry_run_export_usage_data(limit=limit)\n\n    async def initialize_focus_export_job(self) -> None:","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/focus_logger.py#L74-L110","documentation":"FocusLogger.export_usage_data raises this ValueError when exactly one of start_time_utc / end_time_utc is provided (checked with a boolean XOR). This method is the manual export hook (e.g. the /vantage/export endpoint); time bounds must be a complete pair or entirely absent. When both are absent the hook exports all available data instead of a scheduled window.","triggerScenarios":"Calling export_usage_data(start_time_utc=ts) without end_time_utc, or vice versa; an HTTP handler that only forwards the 'start' query parameter; passing datetime(0)-like falsy values — note bool(datetime) is True for any real datetime, so this is purely the one-sided case.","commonSituations":"Building a custom export endpoint where only the start timestamp is wired up; clients sending ?start=... without ?end=...; UI date-range pickers where the user clears one of the two fields.","solutions":["Pass both bounds together: export_usage_data(start_time_utc=start, end_time_utc=end).","Or pass neither to export all available data: export_usage_data(limit=1000).","In HTTP handlers, require start and end as a pair (422 on partial input) instead of forwarding them blindly.","If only a start is known, compute end = start + timedelta(hours=1) (or another window) before calling."],"exampleFix":"# before\nawait logger.export_usage_data(start_time_utc=start_dt)  # XOR -> ValueError\n\n# after\nawait logger.export_usage_data(start_time_utc=start_dt, end_time_utc=start_dt + timedelta(hours=1))","handlingStrategy":"validation","validationCode":"if bool(start_time_utc) ^ bool(end_time_utc):\n    raise HTTPException(422, 'start_time_utc and end_time_utc must be provided together')\nawait logger.export_usage_data(limit=limit, start_time_utc=start_time_utc, end_time_utc=end_time_utc)","typeGuard":"def is_complete_time_range(start: datetime | None, end: datetime | None) -> bool:\n    return (start is None) == (end is None)","tryCatchPattern":"try:\n    await logger.export_usage_data(start_time_utc=s, end_time_utc=e)\nexcept ValueError as e:\n    if 'together' in str(e):\n        return JSONResponse({'error': 'Provide both start and end, or neither'}, 422)\n    raise","preventionTips":["Enforce start/end as a pair at the API boundary (both required or both forbidden).","Derive one bound from the other when only a window start is known.","Remember omitting both exports ALL data — bound the call explicitly when you only want a window."],"tags":["focus-export","parameter-validation","time-range"],"backgroundTag":"parameter-pair-required","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}