From d00834723fa4b964827daa6ae64207dcaba7fa98 Mon Sep 17 00:00:00 2001 From: Michael Fyffe <6224270+TraGicCode@users.noreply.github.com> Date: Mon, 6 Jul 2026 11:20:21 -0500 Subject: [PATCH] Fix issue on endpoint list when no heartbeat info is available --- .../Endpoint/ListEndpointsCommand.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs b/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs index 9f720012..a1040494 100644 --- a/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs +++ b/src/BuslyCLI.Console/Commands/ServiceControl/Endpoint/ListEndpointsCommand.cs @@ -5,14 +5,20 @@ namespace BuslyCLI.Commands.ServiceControl.Endpoint; -public class ListEndpointsCommand(IAnsiConsole console, INServiceBusConfiguration nservicebusConfiguration, ServiceControlClient serviceControlClient) +public class ListEndpointsCommand( + IAnsiConsole console, + INServiceBusConfiguration nservicebusConfiguration, + ServiceControlClient serviceControlClient) : AsyncCommand { - protected override async Task ExecuteAsync(CommandContext context, ListEndpointsSettings settings, CancellationToken cancellationToken) + protected override async Task ExecuteAsync(CommandContext context, ListEndpointsSettings settings, + CancellationToken cancellationToken) { var config = await nservicebusConfiguration.GetServiceControlValidatedConfigurationAsync(settings.Config.Path); - var endpoints = await serviceControlClient.GetEndpointsAsync(config.CurrentServiceControlInstanceConfig.Url, cancellationToken); + var endpoints = + await serviceControlClient.GetEndpointsAsync(config.CurrentServiceControlInstanceConfig.Url, + cancellationToken); var table = new Table(); table.AddColumn("Id"); @@ -29,8 +35,13 @@ protected override async Task ExecuteAsync(CommandContext context, ListEndp endpoint.Name, endpoint.HostDisplayName, endpoint.IsSendingHeartbeats ? "Yes" : "No", - endpoint.HeartbeatInformation.ReportedStatus == "dead" ? "[red]Dead[/]" : "[green]Alive[/]", - endpoint.HeartbeatInformation.LastReportAt.ToString("u")); + endpoint.HeartbeatInformation switch + { + null => "No data available", + { ReportedStatus: "dead" } => "[red]Dead[/]", + _ => "[green]Alive[/]" + }, + endpoint.HeartbeatInformation?.LastReportAt.ToString("u") ?? "-"); } console.Write(table);