[pve-devel] [RFC storage v2 1/3] api: smart: return unknown health instead of error message

Daniel Kral d.kral at proxmox.com
Tue Apr 15 09:11:21 CEST 2025


In case of an error, the WebGUI expects the SMART data API endpoint to
return a health value, but it will return an error message directly. To
make this more user friendly, mask the error in the API handler.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
This could also have been intentional as the error message is passed to
the CLI and API response correctly, which is why it is a RFC.

 src/PVE/API2/Disks.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index 408bdbe..fe8d08e 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -216,7 +216,9 @@ __PACKAGE__->register_method ({
 
 	my $disk = PVE::Diskmanage::verify_blockdev_path($param->{disk});
 
-	my $result = PVE::Diskmanage::get_smart_data($disk, $param->{healthonly});
+	my $result = eval {
+	    PVE::Diskmanage::get_smart_data($disk, $param->{healthonly})
+	};
 
 	$result->{health} = 'UNKNOWN' if !defined $result->{health};
 	$result = { health => $result->{health} } if $param->{healthonly};
-- 
2.39.5





More information about the pve-devel mailing list