BerriAI/litellm · error · ValueError
start_time_utc is required for getting a payload from GCS…
Error message
start_time_utc is required for getting a payload from GCS Bucket
What it means
GCSBucketLogger.get_request_response_payload raises ValueError when start_time_utc is None. The method searches GCS objects for the request's payload by deriving object names from dates (start day, +1 day, -1 day), so it cannot compute any candidate object keys without at least the request's start time. end_time_utc is accepted as None, but start_time_utc is mandatory.
Solutions
- Always pass the request's start_time_utc — fetch it from your spend/logs DB row for that request_id first.
- If the start time is unknown, query your logging DB (e.g. LiteLLMSpendLogs) for start_time by request_id before calling.
- Return a 4xx from your handler when start_time is unavailable rather than calling with None.
- Remember the method tolerates end_time_utc=None; only start is required.
Example fix
# before payload = await logger.get_request_response_payload(req_id, None, None) # after row = await get_spend_log(request_id=req_id) # has start_time payload = await logger.get_request_response_payload(req_id, row.start_time, row.end_time)
Defensive patterns
Strategy: validation
Validate before calling
if start_time_utc is None:
row = await fetch_spend_log(request_id=request_id)
if row is None or row.start_time is None:
return JSONResponse({'error': 'start_time required to fetch GCS payload'}, 400)
start_time_utc = row.start_time Type guard
def has_start_time(start: datetime | None) -> bool:
return start is not None Try / catch
try:
payload = await logger.get_request_response_payload(request_id, start_time_utc, end_time_utc)
except ValueError as e:
if 'start_time_utc is required' in str(e):
return JSONResponse({'error': 'start_time_utc missing for request'}, 400)
raise Prevention
- Always join the request's start_time from your spend-logs DB before calling.
- Treat a NULL start_time in the DB as 'payload not retrievable', not as None to pass through.
When it happens
Trigger: Calling get_request_response_payload(request_id, None, None); an API handler that looks up a request by ID only and forwards a null start_time_utc; DB rows where the start_time column is missing so callers pass None.
Common situations: Building admin/debug endpoints that fetch the raw payload for a logged request; integrations that join against a spend-logs table where start_time can be NULL; forgetting that the GCS layout is date-partitioned.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- bucket_name must be provided for GCS destination
- Failed to import file into RAG corpus
- FOCUS_GCS_BUCKET_NAME must be provided for GCS exports
- GCS Bucket does not support health check
- gcs_bucket is required for Vertex AI RAG ingestion. Set via…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/b1044d5ab916a5c9.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/gcs_bucket/gcs_bucket.py:316
if "gcs_log_id" in _metadata:
safe_log_id: Final = sanitize_cloud_object_component(_metadata.get("gcs_log_id"), fallback="")
if safe_log_id:
object_name = f"{current_date}/custom-{uuid.uuid4().hex}-{safe_log_id}"
return object_name
async def get_request_response_payload(
self,
request_id: str,
start_time_utc: datetime | None,
end_time_utc: datetime | None,
) -> dict | None:
"""
Get the request and response payload for a given `request_id`
Tries current day, next day, and previous day until it finds the payload
"""
if start_time_utc is None:
raise ValueError("start_time_utc is required for getting a payload from GCS Bucket")
dates_to_try: Final = [
start_time_utc,
start_time_utc + timedelta(days=1),
start_time_utc - timedelta(days=1),
]
date_str = None
for date in dates_to_try:
try:
date_str = self._get_object_date_from_datetime(datetime_obj=date)
object_name = self._generate_success_object_name(
request_date_str=date_str,
response_id=request_id,
)
response = await self.download_gcs_object(object_name)
if response is not None:
loaded_response = json.loads(response)View on GitHub (pinned to 77b7c6c40c)