{"record":{"id":"c5e491a8e7250203","repo":"Budibase/budibase","slug":"agent-log-detail-not-found","errorCode":null,"errorMessage":"Agent log detail not found","messagePattern":"Agent log detail not found","errorType":"http","errorClass":"HTTPError","httpStatus":404,"severity":"warning","filePath":"packages/server/src/sdk/workspace/ai/agentLogs/liteLLM.ts","lineNumber":166,"sourceCode":"    throw new Error(\n      `Error fetching agent log detail: ${text || response.statusText}`\n    )\n  }\n\n  return (await response.json()) as LiteLLMRequestPayload\n}\n\nexport async function fetchLiteLLMRequestRaw(\n  agentId: string,\n  requestId: string\n): Promise<LiteLLMRequestDetail> {\n  const [payload, summary] = await Promise.all([\n    fetchLiteLLMRequestPayloadById(requestId),\n    fetchLiteLLMRequestSummaryById(requestId),\n  ])\n\n  if (!payload) {\n    throw new HTTPError(\"Agent log detail not found\", 404)\n  }\n  const data: LiteLLMRequestDetail = {\n    request_id: requestId,\n    model: summary?.model,\n    prompt_tokens: summary?.prompt_tokens,\n    completion_tokens: summary?.completion_tokens,\n    spend: summary?.spend,\n    status: summary?.status,\n    startTime: summary?.startTime,\n    endTime: summary?.endTime,\n    end_user: summary?.end_user,\n    user: summary?.user,\n    metadata: summary?.metadata,\n    response: payload.response,\n    proxy_server_request: payload.proxy_server_request,\n  }\n\n  validateLiteLLMRequestOwnership(agentId, data)","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/agentLogs/liteLLM.ts#L148-L184","documentation":"fetchLiteLLMRequestRaw combines the payload and summary for a request id and throws HTTPError 404 'Agent log detail not found' when LiteLLM has no payload for that id (payload fetch returned null). This distinguishes 'log does not exist' from upstream HTTP failures, which are thrown separately by the sub-fetches.","triggerScenarios":"GET on an agent log detail endpoint with a requestId that was never logged by LiteLLM, a request older than LiteLLM's log retention window, a request id from a different LiteLLM instance/environment, or a malformed/truncated id that LiteLLM answers with 404.","commonSituations":"Developer copies a request_id from a different app/environment; LiteLLM pruned old spend logs; UI bookmarked a log that has since been deleted; typo'd id passed in the URL.","solutions":["Verify the requestId exists in LiteLLM directly: GET $AGENT_LITELLM_URL/requests/{id} with the master key","Confirm you are pointed at the same LiteLLM instance/environment that produced the log","Check LiteLLM log retention/cleanup settings if the log previously existed","Handle the 404 in the UI as 'log no longer available' rather than retrying"],"exampleFix":"// before\nif (!payload) {\n  throw new HTTPError(\"Agent log detail not found\", 404)\n}\n// after\nif (!payload) {\n  throw new HTTPError(`Agent log detail not found for request_id ${requestId}`, 404)\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function isAgentLogDetail(v: unknown): v is LiteLLMRequestDetail {\n  return typeof v === \"object\" && v !== null && \"request_id\" in v\n}","tryCatchPattern":"try {\n  const detail = await fetchLiteLLMRequestRaw(requestId)\n  return detail\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 404) {\n    return null // log pruned or wrong environment\n  }\n  throw err\n}","preventionTips":["Confirm request ids come from the same LiteLLM environment","Check LiteLLM log retention windows","Don't retry 404s — the log simply doesn't exist","Validate ids copied between environments"],"tags":["http-404","agent-logs","litellm","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}