diff --git a/tool/tctl/common/bots_command.go b/tool/tctl/common/bots_command.go index 63f302308f6d0..f20880ef0e426 100644 --- a/tool/tctl/common/bots_command.go +++ b/tool/tctl/common/bots_command.go @@ -581,7 +581,15 @@ func (c *BotsCommand) ListBotInstances(ctx context.Context, client *authclient.C } if c.format == teleport.JSON { - err := utils.WriteJSONArray(c.stdout, instances) + // Wrap resource type so the correct protojson marshaling is used for + // timestamp fields. + wrappedInstances := make([]types.Resource, 0, len(instances)) + for _, instance := range instances { + wrappedInstances = append( + wrappedInstances, types.ProtoResource153ToLegacy(instance), + ) + } + err := utils.WriteJSONArray(c.stdout, wrappedInstances) if err != nil { return trace.Wrap(err, "failed to marshal bot instances") } diff --git a/tool/tctl/common/collection.go b/tool/tctl/common/collection.go index 0346b45060dc8..4444883f28c6f 100644 --- a/tool/tctl/common/collection.go +++ b/tool/tctl/common/collection.go @@ -1756,7 +1756,7 @@ type botInstanceCollection struct { func (c *botInstanceCollection) resources() []types.Resource { r := make([]types.Resource, 0, len(c.items)) for _, resource := range c.items { - r = append(r, types.Resource153ToLegacy(resource)) + r = append(r, types.ProtoResource153ToLegacy(resource)) } return r }