]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/CLIFormatter.pm
fix #1914: CLIFormatter: check also for existence of 'type'
[pve-common.git] / src / PVE / CLIFormatter.pm
index 411da5ddd3cce6989b407aacd3e4cab954710564..3040323eff0f480fe096fbdf1be2c196e80181b3 100644 (file)
@@ -76,8 +76,8 @@ sub render_bytes {
         $max_unit = int(log($value)/log(1024));
         $value /= 1024**($max_unit);
     }
-
-    return sprintf "%.2f $units[$max_unit]", $value;
+    my $unit = $units[$max_unit];
+    return sprintf "%.2f $unit", $value;
 }
 
 PVE::JSONSchema::register_renderer('bytes', \&render_bytes);
@@ -409,7 +409,7 @@ sub print_api_result {
 
     my $format = $options->{'output-format'} // 'text';
 
-    if (!$result_schema) {
+    if ($result_schema && defined($result_schema->{type})) {
        return if $result_schema->{type} eq 'null';
     } else {
        my $type = $guess_type->($data);