From c0b8717c443436d724f4e0be9cfce725d8123df0 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 13 May 2019 06:52:19 +0000 Subject: [PATCH] print api res: always allow result to be undef if optional MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the return schema says that it's optionally returns something then we want to allow returning nothing, i.e., undef Co-developed-by: Dominic Jäger Signed-off-by: Thomas Lamprecht --- src/PVE/CLIFormatter.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm index e886db5..84dbed1 100644 --- a/src/PVE/CLIFormatter.pm +++ b/src/PVE/CLIFormatter.pm @@ -413,6 +413,7 @@ sub print_api_result { if ($result_schema && defined($result_schema->{type})) { return if $result_schema->{type} eq 'null'; + return if $result_schema->{optional} && !defined($data); } else { my $type = $guess_type->($data); $result_schema = { type => $type }; -- 2.39.2