public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shan Shaji <s.shaji@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve_flutter_frontend] fix: spice: replace wrong error message when the VMs or CTs are off
Date: Fri, 18 Jul 2025 13:21:21 +0200	[thread overview]
Message-ID: <20250718112121.137040-1-s.shaji@proxmox.com> (raw)

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


                 reply	other threads:[~2025-07-18 11:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250718112121.137040-1-s.shaji@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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