Skip to content

Commit 751990d

Browse files
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent e8495b0 commit 751990d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/Service/HealthCheck/HealthCheckHelper.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,19 @@ private async Task UpdateMcpHealthCheckResultsAsync(ComprehensiveHealthCheckRepo
244244
// Executes the MCP Query and keeps track of the response time and error message.
245245
private async Task<(int, string?)> ExecuteMcpQueryAsync(string mcpUriSuffix, string roleHeader, string roleToken)
246246
{
247-
string? errorMessage = null;
248-
if (!string.IsNullOrEmpty(mcpUriSuffix))
247+
if (string.IsNullOrEmpty(mcpUriSuffix))
249248
{
250-
Stopwatch stopwatch = new();
251-
stopwatch.Start();
252-
errorMessage = await _httpUtility.ExecuteMcpQueryAsync(mcpUriSuffix, roleHeader, roleToken);
253-
stopwatch.Stop();
254-
return string.IsNullOrEmpty(errorMessage) ? ((int)stopwatch.ElapsedMilliseconds, errorMessage) : (HealthCheckConstants.ERROR_RESPONSE_TIME_MS, errorMessage);
249+
return (HealthCheckConstants.ERROR_RESPONSE_TIME_MS, "MCP is enabled but no MCP path is configured.");
255250
}
256251

257-
return (HealthCheckConstants.ERROR_RESPONSE_TIME_MS, errorMessage);
252+
Stopwatch stopwatch = new();
253+
stopwatch.Start();
254+
string? errorMessage = await _httpUtility.ExecuteMcpQueryAsync(mcpUriSuffix, roleHeader, roleToken);
255+
stopwatch.Stop();
256+
257+
return string.IsNullOrEmpty(errorMessage)
258+
? ((int)stopwatch.ElapsedMilliseconds, errorMessage)
259+
: (HealthCheckConstants.ERROR_RESPONSE_TIME_MS, errorMessage);
258260
}
259261

260262
// Updates the Entity Health Check Results in the response.

0 commit comments

Comments
 (0)