microsoft/aspire · error · McpProtocolException
InternalError
InternalError
Error message
{errorMessage: 'Failed to fetch structured logs for trace: {ex.Message}' or dashboard API error message} What it means
Thrown by ListTraceStructuredLogsTool.CallToolAsync when the HTTP call to the dashboard API for a trace's structured logs raises HttpRequestException. Message is either the dashboard API's own error text (direct connection) or 'Failed to fetch structured logs for trace: <ex.Message>'; code InternalError (-32603).
Solutions
- Confirm the dashboard API base URL is reachable and retry the trace query.
- Restart the AppHost (or re-fetch dashboard info) to refresh endpoints and token.
- Check proxies/firewalls/DNS for the dashboard host.
- Read the underlying HttpRequestException in the CLI logs ('Failed to fetch structured logs for trace from Dashboard API') for the socket-level cause.
Defensive patterns
Strategy: retry
Validate before calling
// Ensure dashboard API reachability before trace log queries var response = await httpClient.GetAsync(apiBaseUrl, HttpCompletionOption.ResponseHeadersRead, ct); response.EnsureSuccessStatusCode();
Try / catch
try
{
await ListTraceStructuredLogsAsync(traceId);
}
catch (McpProtocolException ex) when (ex.Message.Contains("Failed to fetch structured logs for trace"))
{
// Refresh dashboard endpoints/token and retry once
await RefreshDashboardInfoAsync();
await ListTraceStructuredLogsAsync(traceId);
} Prevention
- Obtain fresh dashboard info after AppHost restarts before trace queries.
- Verify trace IDs exist and the app is still emitting telemetry.
- Check proxy/DNS/firewall reachability of the dashboard API host.
- Retry transient network failures with a short backoff.
When it happens
Trigger: Requesting structured logs for a specific trace ID while the dashboard API endpoint is unreachable, the base URL/token is stale, or the proxied connection fails mid-request.
Common situations: AppHost/dashboard restarted so cached dashboard info is stale; telemetry endpoint temporarily unavailable; network proxy interference; trace requested concurrently with app shutdown.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/258e494821a75c98.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Mcp/Tools/ListTraceStructuredLogsTool.cs:131
{limitMessage}
# STRUCTURED LOGS DATA
{logsData}
""";
return new CallToolResult
{
Content = [new TextContentBlock { Text = text }]
};
}
catch (HttpRequestException ex)
{
logger.LogError(ex, "Failed to fetch structured logs for trace from Dashboard API");
var errorMessage = dashboardInfoProvider.IsDirectConnection
? await TelemetryCommandHelpers.GetDashboardApiErrorMessageAsync(ex, apiBaseUrl, httpClientFactory, logger, cancellationToken)
: $"Failed to fetch structured logs for trace: {ex.Message}";
throw new McpProtocolException(errorMessage, McpErrorCode.InternalError);
}
}
}
View on GitHub (pinned to 25830f84bd)