[pve-devel] [PATCH storage 3/3] api: prevent null as return value for property type string

Tim Marx t.marx at proxmox.com
Mon Dec 9 14:30:28 CET 2019


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
 PVE/API2/Cluster.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 0020d2ea..ed422daa 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -636,13 +636,16 @@ __PACKAGE__->register_method({
 		    id => "node/$node",
 		    name => $node,
 		    nodeid => $d->{id},
-		    ip => $d->{ip},
 		    'local' => ($node eq $nodename) ? 1 : 0,
 		    online => $d->{online},
 		};
 
+		if (defined($d->{ip})) {
+		    $entry->{ip} = $d->{ip};
+		}
+
 		if (my $d = PVE::API2Tools::extract_node_stats($node, $members, $rrd)) {
-		    $entry->{level} = $d->{level};
+		    $entry->{level} = $d->{level} || '';
 		}
 
 		push @$res, $entry;
-- 
2.20.1



More information about the pve-devel mailing list