The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: show error details instead of Data Not Available for failed requests (#20656)
Varun Chawla7335965c1284
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsxindex 54946eb0964..a3f948296eb 100644--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx@@ -85,7 +85,7 @@ export function LogDetailsDrawer({// Check if request/response data is presentconst hasMessages = checkHasMessages(logEntry.messages);const hasResponse = checkHasResponse(logEntry.response);- const missingData = !hasMessages && !hasResponse;+ const missingData = !hasMessages && !hasResponse && !hasError;// Guardrail dataconst guardrailInfo = metadata?.guardrail_information;@@ -206,6 +206,7 @@ export function LogDetailsDrawer({{/* Request/Response JSON - Collapsible */}<RequestResponseSectionhasResponse={hasResponse}+ hasError={hasError}getRawRequest={getRawRequest}getFormattedResponse={getFormattedResponse}logEntry={logEntry}@@ -339,6 +340,7 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata:interface RequestResponseSectionProps {hasResponse: boolean;+ hasError: boolean;getRawRequest: () => any;getFormattedResponse: () => any;logEntry: LogEntry;@@ -346,6 +348,7 @@ interface RequestResponseSectionProps {function RequestResponseSection({hasResponse,+ hasError,getRawRequest,getFormattedResponse,logEntry,@@ -423,7 +426,7 @@ function RequestResponseSection({text: getCopyText(),tooltips: ["Copy JSON", "Copied!"]}}- disabled={activeTab === TAB_RESPONSE && !hasResponse}+ disabled={activeTab === TAB_RESPONSE && !hasResponse && !hasError}/>}items={[@@ -441,7 +444,7 @@ function RequestResponseSection({label: "Response",children: (<div style={{ paddingTop: SPACING_XLARGE, paddingBottom: SPACING_XLARGE }}>- {hasResponse ? (+ {hasResponse || hasError ? (<JsonViewer data={getFormattedResponse()} mode="formatted" />) : (<div style={{ textAlign: "center", padding: 20, color: "#999", fontStyle: "italic" }}>diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.test.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.test.tsxindex deeac3a8d0b..b7c0318d9fd 100644--- a/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.test.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.test.tsx@@ -188,4 +188,78 @@ describe("RequestResponsePanel", () => {expect(responseData).toEqual({ responseData: "this should appear in response" });expect(responseData).not.toEqual({ requestData: "this should not appear in response" });});++ it("should show error response data when hasError is true and hasResponse is false", () => {+ const failedLogEntry: LogEntry = {+ ...baseLogEntry,+ messages: [],+ response: {},+ metadata: {+ status: "failure",+ error_information: {+ error_message: "Model not found",+ error_class: "NotFoundError",+ error_code: 404,+ },+ additional_usage_values: {+ cache_read_input_tokens: 0,+ cache_creation_input_tokens: 0,+ },+ },+ };+ const errorResponse = { error: { message: "Model not found", type: "NotFoundError", code: 404, param: null } };+ const mockGetRawRequest = vi.fn().mockReturnValue({ messages: [] });+ const mockFormattedResponse = vi.fn().mockReturnValue(errorResponse);+ render(+ <RequestResponsePanel+ row={{ original: failedLogEntry }}+ hasMessages={false}+ hasResponse={false}+ hasError={true}+ errorInfo={failedLogEntry.metadata.error_information}+ getRawRequest={mockGetRawRequest}+ formattedResponse={mockFormattedResponse}+ />,+ );+ expect(screen.queryByText("Response data not available")).not.toBeInTheDocument();+ expect(mockFormattedResponse).toHaveBeenCalled();+ const copyButtons = screen.getAllByRole("button");+ const copyResponseButton = copyButtons.find((button) => button.getAttribute("title") === "Copy response");+ expect(copyResponseButton).not.toBeDisabled();+ });++ it("should show Response data not available when hasResponse and hasError are both false", () => {+ const mockGetRawRequest = vi.fn().mockReturnValue({ messages: [] });+ const mockFormattedResponse = vi.fn().mockReturnValue({});+ render(+ <RequestResponsePanel+ row={{ original: baseLogEntry }}+ hasMessages={false}+ hasResponse={false}+ hasError={false}+ errorInfo={null}+ getRawRequest={mockGetRawRequest}+ formattedResponse={mockFormattedResponse}+ />,+ );+ expect(screen.getByText("Response data not available")).toBeInTheDocument();+ });++ it("should show error code in response header when hasError is true", () => {+ const errorInfo = { error_message: "Rate limit exceeded", error_class: "RateLimitError", error_code: 429 };+ const mockGetRawRequest = vi.fn().mockReturnValue({ messages: [] });+ const mockFormattedResponse = vi.fn().mockReturnValue({ error: { message: "Rate limit exceeded", type: "RateLimitError", code: 429, param: null } });+ render(+ <RequestResponsePanel+ row={{ original: baseLogEntry }}+ hasMessages={false}+ hasResponse={false}+ hasError={true}+ errorInfo={errorInfo}+ getRawRequest={mockGetRawRequest}+ formattedResponse={mockFormattedResponse}+ />,+ );+ expect(screen.getByText(/HTTP code 429/)).toBeInTheDocument();+ });});diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.tsxindex b2cae68184a..da9323f8172 100644--- a/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/RequestResponsePanel.tsx@@ -113,7 +113,7 @@ export function RequestResponsePanel({onClick={handleCopyResponse}className="p-1 hover:bg-gray-200 rounded"title="Copy response"- disabled={!hasResponse}+ disabled={!hasResponse && !hasError}><svgxmlns="http://www.w3.org/2000/svg"@@ -132,7 +132,7 @@ export function RequestResponsePanel({</button></div><div className="p-4 overflow-auto max-h-96 w-full max-w-full box-border">- {hasResponse ? (+ {hasResponse || hasError ? (<div className="[&_[role='tree']]:bg-white [&_[role='tree']]:text-slate-900"><JsonView data={formattedResponse()} style={defaultStyles} clickToExpandNode /></div>diff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsxindex 3859a5e51fb..87e11e00c7c 100644--- a/ui/litellm-dashboard/src/components/view_logs/index.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx@@ -822,7 +822,7 @@ export function RequestViewer({ row, onOpenSettings }: { row: Row<LogEntry>; onO? row.original.messages.length > 0: Object.keys(row.original.messages).length > 0);const hasResponse = row.original.response && Object.keys(formatData(row.original.response)).length > 0;- const missingData = !hasMessages && !hasResponse;+ const missingData = !hasMessages && !hasResponse && !hasError;// Format the response with error details if presentconst formattedResponse = () => {