{"record":{"id":"b1044d5ab916a5c9","repo":"BerriAI/litellm","slug":"start-time-utc-is-required-for-getting-a-payload-f","errorCode":null,"errorMessage":"start_time_utc is required for getting a payload from GCS Bucket","messagePattern":"start_time_utc is required for getting a payload from GCS Bucket","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gcs_bucket/gcs_bucket.py","lineNumber":316,"sourceCode":"        if \"gcs_log_id\" in _metadata:\n            safe_log_id: Final = sanitize_cloud_object_component(_metadata.get(\"gcs_log_id\"), fallback=\"\")\n            if safe_log_id:\n                object_name = f\"{current_date}/custom-{uuid.uuid4().hex}-{safe_log_id}\"\n\n        return object_name\n\n    async def get_request_response_payload(\n        self,\n        request_id: str,\n        start_time_utc: datetime | None,\n        end_time_utc: datetime | None,\n    ) -> dict | None:\n        \"\"\"\n        Get the request and response payload for a given `request_id`\n        Tries current day, next day, and previous day until it finds the payload\n        \"\"\"\n        if start_time_utc is None:\n            raise ValueError(\"start_time_utc is required for getting a payload from GCS Bucket\")\n\n        dates_to_try: Final = [\n            start_time_utc,\n            start_time_utc + timedelta(days=1),\n            start_time_utc - timedelta(days=1),\n        ]\n        date_str = None\n        for date in dates_to_try:\n            try:\n                date_str = self._get_object_date_from_datetime(datetime_obj=date)\n                object_name = self._generate_success_object_name(\n                    request_date_str=date_str,\n                    response_id=request_id,\n                )\n                response = await self.download_gcs_object(object_name)\n\n                if response is not None:\n                    loaded_response = json.loads(response)","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gcs_bucket/gcs_bucket.py#L298-L334","documentation":"GCSBucketLogger.get_request_response_payload raises ValueError when start_time_utc is None. The lookup strategy derives object names from the request date (trying same day, +1 day, -1 day), so without a start time there is no way to locate the object in the bucket.","triggerScenarios":"Calling get_request_response_payload(request_id, None, end_time_utc) — typically a caller passing an optional start_time that was never populated, or a request record whose start_time field is missing.","commonSituations":"Proxy UI/API fetching a logged payload for a request whose metadata lacks a start timestamp; refactoring that made start_time optional without handling None.","solutions":["Pass the request's start_time (UTC) — e.g. from the spend/logs DB record for that request_id.","If start_time is genuinely unavailable, fetch the log row first to recover it before calling this method.","Guard at the call site: skip/return early when start_time_utc is None."],"exampleFix":"# before\npayload = await gcs_logger.get_request_response_payload(request_id, None, None)\n\n# after\nif start_time_utc is None:\n    return None\npayload = await gcs_logger.get_request_response_payload(request_id, start_time_utc, None)","handlingStrategy":"validation","validationCode":"if start_time_utc is None:\n    return None  # or fetch the log row to obtain start_time first\npayload = await gcs_logger.get_request_response_payload(request_id, start_time_utc, end_time_utc)","typeGuard":"def has_start_time(d: datetime | None) -> bool:\n    return d is not None","tryCatchPattern":null,"preventionTips":["Always source start_time from the request's log record before asking GCS for the payload.","Make the field required in your request-fetch API rather than optional.","Return a clear 'payload unavailable' response instead of propagating the ValueError to clients."],"tags":["gcs","validation","api-misuse","logging-callback"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}