From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B47D71FF15C for ; Fri, 11 Jul 2025 12:04:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 28118D54E; Fri, 11 Jul 2025 12:05:15 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 11 Jul 2025 12:04:42 +0200 Message-Id: <20250711100442.2472847-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager] ui: upload: catch non-json responses X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" when the responseText contains a plain message instead of JSON, the code would throw an exception here that we don't catch and not show an error, but also not progressing with the upload. Catch the error, and show the originally generated message if responseText is not valid JSON. Signed-off-by: Dominik Csapak --- While testing upload errors to see if we can get a better error message than 'Error 0 occurred', i noticed that in chrome we fail here to show the valid error message. Note that this does not improve the 'Error 0' message, only cases where the browser fails on a different path. www/manager6/window/UploadToStorage.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/www/manager6/window/UploadToStorage.js b/www/manager6/window/UploadToStorage.js index cc53596d..96d8dabf 100644 --- a/www/manager6/window/UploadToStorage.js +++ b/www/manager6/window/UploadToStorage.js @@ -115,9 +115,14 @@ Ext.define('PVE.window.UploadToStorage', { const err = Ext.htmlEncode(xhr.statusText); let msg = `${gettext('Error')} ${xhr.status.toString()}: ${err}`; if (xhr.responseText !== '') { - const result = Ext.decode(xhr.responseText); - result.message = msg; - msg = Proxmox.Utils.extractRequestError(result, true); + try { + const result = Ext.decode(xhr.responseText); + result.message = msg; + msg = Proxmox.Utils.extractRequestError(result, true); + } catch (_e) { + // we could not decode the responseText, so it's + // probably not json, so show initial error message + } } Ext.Msg.alert(gettext('Error'), msg, (btn) => view.close()); }, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel