Budibase/budibase · error

Error fetching agent session detail: ${text || response.stat

Error message

Error fetching agent session detail: ${text || response.statusText}

What it means

fetchLiteLLMSessionRows pages through LiteLLM's /requests endpoint for a session and throws this Error when any page returns a non-ok, non-404 status. 404 is treated as an empty result set ({rows: [], total: 0}); any other failure aborts session detail assembly with the LiteLLM error body in the message.

Source

Thrown at packages/server/src/sdk/workspace/ai/agentLogs/liteLLM.ts:116

      page: String(page),
      page_size: String(pageSize),
    })
    const response = await fetch(
      `${liteLLMUrl}/spend/logs/session/ui?${params.toString()}`,
      {
        headers: {
          Authorization: liteLLMAuthorizationHeader,
        },
      }
    )

    if (response.status === 404) {
      return { rows: [], total: 0 }
    }

    if (!response.ok) {
      const text = await response.text()
      throw new Error(
        `Error fetching agent session detail: ${text || response.statusText}`
      )
    }

    const data = (await response.json()) as LiteLLMRequestListResponse
    rows.push(...(data.data || []))
    total = data.total || total || rows.length
    totalPages = data.total_pages || 1
    page += 1
  }

  return { rows, total }
}

async function fetchLiteLLMRequestPayloadById(
  requestId: string
): Promise<LiteLLMRequestPayload | null> {
  const response = await fetch(

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Confirm the LiteLLM base URL and API key env vars match the running proxy; restart the server after key changes
  2. Check LiteLLM logs / its Postgres DB health when the body shows an internal error
  3. Test the exact /requests route manually with curl using the same auth header to see the real upstream message
  4. Add retry logic for transient 5xx statuses before surfacing the error

Example fix

// before
throw new Error(`Error fetching agent session detail: ${text || response.statusText}`)
// after
const err = new Error(`Error fetching agent session detail: ${text || response.statusText}`)
;(err as any).status = response.status
throw err
Defensive patterns

Strategy: retry

Validate before calling

const res = await fetch(`${base}/requests?session_id=${sessionId}`, { headers: { Authorization: `Bearer ${key}` } })
if (res.status === 401) throw new Error("LiteLLM authentication failed")

Try / catch

try {
  const session = await getSessionDetail(sessionId)
} catch (err) {
  console.error("Session detail fetch failed", err)
  return { rows: [], total: 0 }
}

Prevention

When it happens

Trigger: Calling fetchLiteLLMSessionRows (via session detail endpoints) when LiteLLM returns e.g. 401 Unauthorized due to a bad key, 500 because LiteLLM's spend-log database is unavailable, or 502 when the proxy is down mid-pagination.

Common situations: LITELLM key rotated but server not restarted; LiteLLM proxy container crashed; firewall/DNS change making AGENT_LITELLM_BASE_URL unreachable; LiteLLM version upgrade changing the /requests route shape.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/7d70b723d5651834. Report an issue: GitHub.