[pve-devel] [PATCH manager 2/2] ui: cert upload: fix private key field sending empty string

Max Carrara m.carrara at proxmox.com
Tue Feb 28 17:36:34 CET 2023


The private key's field is now excluded from the upload form's
JSON data if it's considered empty by Ext.js.

Prior to this change, the form still sent an empty string if no
private key was provided by the user, even though the private key's
field is marked as optional in `pve-manager/PVE/API2/Certificates.pm`,
causing the JSONSchema validation to fail.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
 www/manager6/node/Certificates.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/www/manager6/node/Certificates.js b/www/manager6/node/Certificates.js
index 34013b44..4c0b18d1 100644
--- a/www/manager6/node/Certificates.js
+++ b/www/manager6/node/Certificates.js
@@ -173,6 +173,13 @@ Ext.define('PVE.node.CertUpload', {
 	    emptyText: gettext('No change'),
 	    name: 'key',
 	    xtype: 'textarea',
+	    getSubmitValue: function() {
+		let value = this.getValue();
+		if (Ext.isEmpty(value)) {
+		    return null;
+		}
+		return value;
+	    },
 	},
 	{
 	    xtype: 'filebutton',
-- 
2.30.2






More information about the pve-devel mailing list