public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve_flutter_frontend] fix: spice: replace wrong error message when the VMs or CTs are off
@ 2025-07-18 11:21 Shan Shaji
  0 siblings, 0 replies; only message in thread
From: Shan Shaji @ 2025-07-18 11:21 UTC (permalink / raw)
  To: pve-devel

When trying to open the SPICE app from a guest if the guest is not
running, the error message shown was "Ensure you have VM.Console
Permission". However in the API response the `message` property was
returning guest not running message

Fix the issue by using the `message` property to show the error message.
When checking the same behaviour on web UI the error message shown
matches the string from `message` property.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---

 Tested Scenerio 1:
 - Created a custom role without the Sys.Console and VM.Console 
   permissions.
 - Tried opening the SPICE Console and the error message shown is 
   "Permission check failed (/vms/101, VM.Console)"

 Tested Scenerio 2:
 - Tried opening the spice file without turning on the guest
 - The error message shown is "CT 101 not running (500)"

 lib/widgets/pve_console_menu_widget.dart | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/widgets/pve_console_menu_widget.dart b/lib/widgets/pve_console_menu_widget.dart
index cd8c314..cbf4f92 100644
--- a/lib/widgets/pve_console_menu_widget.dart
+++ b/lib/widgets/pve_console_menu_widget.dart
@@ -61,9 +61,17 @@ class PveConsoleMenu extends StatelessWidget {
                     final response = await apiClient.postRequest(apiPath);
                     final data = json.decode(response.body)['data'];
                     if (data == null) {
+                      String errorDescription =
+                          'Ensure you have "${type == 'node' ? 'Sys' : 'VM'}.Console" permissions.';
+                      final message = json.decode(response.body)['message'];
+
+                      if (message != null) errorDescription = message;
                       if (context.mounted) {
-                        showTextDialog(context, 'Empty reply from SPICE API',
-                            'Ensure you have "${type == 'node' ? 'Sys' : 'VM'}.Console" permissions.');
+                        showTextDialog(
+                          context,
+                          'Empty reply from SPICE API',
+                          errorDescription,
+                        );
                       }
                       return;
                     }
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-18 11:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-18 11:21 [pve-devel] [PATCH pve_flutter_frontend] fix: spice: replace wrong error message when the VMs or CTs are off Shan Shaji

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal