diff --git a/src/public/js/ui/settings.js b/src/public/js/ui/settings.js
index b2190de61..2d4704c58 100644
--- a/src/public/js/ui/settings.js
+++ b/src/public/js/ui/settings.js
@@ -72,11 +72,14 @@ PulseApp.ui.settings = (() => {
// Load current configuration
try {
await loadCurrentConfig();
- renderConfigurationForm();
} catch (error) {
console.error('[Settings] Failed to load configuration:', error);
- body.innerHTML = `
Failed to load configuration: ${error.message}
`;
+ // Initialize with empty config to prevent errors
+ currentConfig = {};
}
+
+ // Always render the form, even if config loading failed
+ renderConfigurationForm();
}
function closeModal() {
@@ -96,7 +99,8 @@ PulseApp.ui.settings = (() => {
throw new Error(`HTTP ${response.status}`);
}
- currentConfig = await response.json();
+ const configData = await response.json();
+ currentConfig = configData || {}; // Ensure we never have null/undefined
console.log('[Settings] Current config loaded:', currentConfig);
} catch (error) {
@@ -109,6 +113,13 @@ PulseApp.ui.settings = (() => {
const body = document.getElementById('settings-modal-body');
if (!body) return;
+ // Ensure currentConfig has a safe default structure
+ const safeConfig = currentConfig || {};
+ const proxmox = safeConfig.proxmox || {};
+ const pbs = safeConfig.pbs || {};
+ const advanced = safeConfig.advanced || {};
+ const alerts = advanced.alerts || {};
+
const html = `