{"record":{"id":"6b0425f8b06dc2f9","repo":"microsoft/aspire","slug":"internalerror-errormessage-failed-to-fetch-traces-ex-message","errorCode":"InternalError","errorMessage":"{errorMessage: 'Failed to fetch traces: {ex.Message}' or dashboard API error message}","messagePattern":"(.+?)' or dashboard API error message\\}","errorType":"error_code","errorClass":"McpProtocolException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Mcp/Tools/ListTracesTool.cs","lineNumber":141,"sourceCode":"                {limitMessage}\n\n                # TRACES DATA\n\n                {tracesData}\n                \"\"\";\n\n            return new CallToolResult\n            {\n                Content = [new TextContentBlock { Text = text }]\n            };\n        }\n        catch (HttpRequestException ex)\n        {\n            logger.LogError(ex, \"Failed to fetch traces from Dashboard API\");\n            var errorMessage = dashboardInfoProvider.IsDirectConnection\n                ? await TelemetryCommandHelpers.GetDashboardApiErrorMessageAsync(ex, apiBaseUrl, httpClientFactory, logger, cancellationToken)\n                : $\"Failed to fetch traces: {ex.Message}\";\n            throw new McpProtocolException(errorMessage, McpErrorCode.InternalError);\n        }\n    }\n}\n","sourceCodeStart":123,"sourceCodeEnd":145,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Mcp/Tools/ListTracesTool.cs#L123-L145","documentation":"Thrown by ListTracesTool.CallToolAsync when the HTTP request to the dashboard traces endpoint fails with HttpRequestException. In direct mode the dashboard API's error message is surfaced; otherwise 'Failed to fetch traces: <ex.Message>'. Code InternalError (-32603).","triggerScenarios":"Calling the list-traces MCP tool while the dashboard API is unreachable, the apiBaseUrl/token are stale, or the non-direct (proxied) connection throws HttpRequestException.","commonSituations":"Dashboard stopped or port reassigned; stale connection info after AppHost restart; corporate proxy blocking the telemetry endpoint; Docker/network isolation preventing localhost dashboard access.","solutions":["Verify the AppHost/dashboard is running and the apiBaseUrl responds (e.g. curl).","Restart the AppHost and retry to obtain fresh dashboard URLs and token.","Check proxy/firewall/DNS configuration for the dashboard endpoint.","Inspect the CLI log line 'Failed to fetch traces from Dashboard API' for the underlying exception detail."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Health-check the dashboard API before listing traces\nusing var probe = await httpClient.GetAsync(apiBaseUrl, HttpCompletionOption.ResponseHeadersRead, ct);\nif (!probe.IsSuccessStatusCode) { /* refresh dashboard info first */ }","typeGuard":null,"tryCatchPattern":"try\n{\n    await ListTracesAsync();\n}\ncatch (McpProtocolException ex) when (ex.Message.StartsWith(\"Failed to fetch traces\"))\n{\n    // Refresh dashboard URLs/token (stale after restart) and retry once\n    await RefreshDashboardInfoAsync();\n    await ListTracesAsync();\n}","preventionTips":["Re-fetch dashboard info whenever the AppHost restarts or ports change.","Confirm the dashboard endpoint is reachable from the CLI host (curl/apiBaseUrl).","Exclude proxy interference for localhost dashboard traffic if needed.","Use bounded retries for transient HttpRequestExceptions."],"tags":["mcp","http","traces","dashboard-api","aspire-cli"],"backgroundTag":"http-request-failed","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}