[pve-devel] [PATCH common] fix #1914: CLIFormatter: check also for existance of 'type'

Dominik Csapak d.csapak at proxmox.com
Mon Sep 17 10:32:03 CEST 2018


we sometimes define

result => {}

on an api call, so check that result->{type} is defined
and guess the type if not

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/CLIFormatter.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 4702180..3040323 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -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);
-- 
2.11.0





More information about the pve-devel mailing list