Skip to content

Modern Docker Management, Designed for Everyone

fix: missing settings making env settings not able to be saved (#1775)

Kyle Mendell701dba3fb844
diff --git a/.github/.golangci.yml b/.github/.golangci.yml
index 37dd3b863..b80c7e0dc 100644
--- a/.github/.golangci.yml
+++ b/.github/.golangci.yml
@@ -1,6 +1,6 @@
-version: '2'
+version: "2"
run:
- tests: true
+ tests: false
timeout: 5m
linters:
default: none
diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.go
index fbaa2a761..b7a71fa4d 100644
--- a/backend/internal/services/settings_service.go
+++ b/backend/internal/services/settings_service.go
@@ -85,31 +85,34 @@ func (s *SettingsService) LoadDatabaseSettings(ctx context.Context) (err error)
func (s *SettingsService) getDefaultSettings() *models.Settings {
return &models.Settings{
- ProjectsDirectory: models.SettingVariable{Value: "/app/data/projects"},
- DiskUsagePath: models.SettingVariable{Value: "/app/data/projects"},
- AutoUpdate: models.SettingVariable{Value: "false"},
- AutoUpdateInterval: models.SettingVariable{Value: "0 0 0 * * *"},
- PollingEnabled: models.SettingVariable{Value: "true"},
- PollingInterval: models.SettingVariable{Value: "0 0 * * * *"},
- EventCleanupInterval: models.SettingVariable{Value: "0 0 */6 * * *"},
- AnalyticsHeartbeatInterval: models.SettingVariable{Value: "0 0 0 * * *"},
- AutoInjectEnv: models.SettingVariable{Value: "false"},
- PruneMode: models.SettingVariable{Value: "dangling"},
- ScheduledPruneEnabled: models.SettingVariable{Value: "false"},
- ScheduledPruneInterval: models.SettingVariable{Value: "0 0 0 * * *"},
- ScheduledPruneContainers: models.SettingVariable{Value: "true"},
- ScheduledPruneImages: models.SettingVariable{Value: "true"},
- ScheduledPruneVolumes: models.SettingVariable{Value: "false"},
- ScheduledPruneNetworks: models.SettingVariable{Value: "true"},
- ScheduledPruneBuildCache: models.SettingVariable{Value: "false"},
- BaseServerURL: models.SettingVariable{Value: "http://localhost"},
- EnableGravatar: models.SettingVariable{Value: "true"},
- DefaultShell: models.SettingVariable{Value: "/bin/sh"},
- DockerHost: models.SettingVariable{Value: "unix:///var/run/docker.sock"},
- AuthLocalEnabled: models.SettingVariable{Value: "true"},
- AuthSessionTimeout: models.SettingVariable{Value: "1440"},
- AuthPasswordPolicy: models.SettingVariable{Value: "strong"},
- TrivyImage: models.SettingVariable{Value: "ghcr.io/aquasecurity/trivy:latest"},
+ ProjectsDirectory: models.SettingVariable{Value: "/app/data/projects"},
+ DiskUsagePath: models.SettingVariable{Value: "/app/data/projects"},
+ AutoUpdate: models.SettingVariable{Value: "false"},
+ AutoUpdateInterval: models.SettingVariable{Value: "0 0 0 * * *"},
+ AutoUpdateExcludedContainers: models.SettingVariable{Value: ""},
+ PollingEnabled: models.SettingVariable{Value: "true"},
+ PollingInterval: models.SettingVariable{Value: "0 0 * * * *"},
+ EventCleanupInterval: models.SettingVariable{Value: "0 0 */6 * * *"},
+ AnalyticsHeartbeatInterval: models.SettingVariable{Value: "0 0 0 * * *"},
+ AutoInjectEnv: models.SettingVariable{Value: "false"},
+ PruneMode: models.SettingVariable{Value: "dangling"},
+ ScheduledPruneEnabled: models.SettingVariable{Value: "false"},
+ ScheduledPruneInterval: models.SettingVariable{Value: "0 0 0 * * *"},
+ ScheduledPruneContainers: models.SettingVariable{Value: "true"},
+ ScheduledPruneImages: models.SettingVariable{Value: "true"},
+ ScheduledPruneVolumes: models.SettingVariable{Value: "false"},
+ ScheduledPruneNetworks: models.SettingVariable{Value: "true"},
+ ScheduledPruneBuildCache: models.SettingVariable{Value: "false"},
+ BaseServerURL: models.SettingVariable{Value: "http://localhost"},
+ EnableGravatar: models.SettingVariable{Value: "true"},
+ DefaultShell: models.SettingVariable{Value: "/bin/sh"},
+ DockerHost: models.SettingVariable{Value: "unix:///var/run/docker.sock"},
+ AuthLocalEnabled: models.SettingVariable{Value: "true"},
+ AuthSessionTimeout: models.SettingVariable{Value: "1440"},
+ AuthPasswordPolicy: models.SettingVariable{Value: "strong"},
+ VulnerabilityScanEnabled: models.SettingVariable{Value: "false"},
+ VulnerabilityScanInterval: models.SettingVariable{Value: "0 0 0 * * *"},
+ TrivyImage: models.SettingVariable{Value: "ghcr.io/aquasecurity/trivy:latest"},
// AuthOidcConfig DEPRECATED will be removed in a future release
AuthOidcConfig: models.SettingVariable{Value: "{}"},
OidcEnabled: models.SettingVariable{Value: "false"},
diff --git a/backend/internal/services/settings_service_test.go b/backend/internal/services/settings_service_test.go
index 7114138a2..3f168f001 100644
--- a/backend/internal/services/settings_service_test.go
+++ b/backend/internal/services/settings_service_test.go
@@ -42,11 +42,20 @@ func TestSettingsService_EnsureDefaultSettings_Idempotent(t *testing.T) {
require.NoError(t, svc.db.WithContext(ctx).Model(&models.SettingVariable{}).Count(&count2).Error)
require.Equal(t, count1, count2)
- // Spot-check a couple keys exist
- for _, key := range []string{"authLocalEnabled", "projectsDirectory"} {
+ // Spot-check core and automation defaults exist with correct values
+ for _, key := range []string{"authLocalEnabled", "projectsDirectory", "autoUpdateExcludedContainers", "vulnerabilityScanEnabled", "vulnerabilityScanInterval"} {
var sv models.SettingVariable
err := svc.db.WithContext(ctx).Where("key = ?", key).First(&sv).Error
require.NoErrorf(t, err, "missing default key %s", key)
+
+ switch key {
+ case "autoUpdateExcludedContainers":
+ require.Equal(t, "", sv.Value)
+ case "vulnerabilityScanEnabled":
+ require.Equal(t, "false", sv.Value)
+ case "vulnerabilityScanInterval":
+ require.Equal(t, "0 0 0 * * *", sv.Value)
+ }
}
}
diff --git a/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql b/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql
new file mode 100644
index 000000000..be3dedff2
--- /dev/null
+++ b/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql
@@ -0,0 +1,3 @@
+BEGIN;
+-- No-op: data backfill migration cannot be safely reversed.
+COMMIT;
diff --git a/backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql b/backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql
new file mode 100644
index 000000000..51a40e005
--- /dev/null
+++ b/backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql
@@ -0,0 +1,32 @@
+BEGIN;
+
+-- Backfill missing vulnerability scan settings defaults
+INSERT INTO settings (key, value)
+VALUES ('vulnerabilityScanEnabled', 'false')
+ON CONFLICT (key) DO NOTHING;
+
+UPDATE settings
+SET value = 'false'
+WHERE key = 'vulnerabilityScanEnabled'
+ AND (value IS NULL OR btrim(value) = '');
+
+INSERT INTO settings (key, value)
+VALUES ('vulnerabilityScanInterval', '0 0 0 * * *')
+ON CONFLICT (key) DO NOTHING;
+
+UPDATE settings
+SET value = '0 0 0 * * *'
+WHERE key = 'vulnerabilityScanInterval'
+ AND (value IS NULL OR btrim(value) = '');
+
+-- Backfill missing auto-update excluded containers setting
+INSERT INTO settings (key, value)
+VALUES ('autoUpdateExcludedContainers', '')
+ON CONFLICT (key) DO NOTHING;
+
+UPDATE settings
+SET value = ''
+WHERE key = 'autoUpdateExcludedContainers'
+ AND value IS NULL;
+
+COMMIT;
diff --git a/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql b/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql
new file mode 100644
index 000000000..f46fde449
--- /dev/null
+++ b/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql
@@ -0,0 +1 @@
+-- No-op: data backfill migration cannot be safely reversed.
diff --git a/backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql b/backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql
new file mode 100644
index 000000000..abb32653f
--- /dev/null
+++ b/backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql
@@ -0,0 +1,19 @@
+-- Backfill missing vulnerability scan settings defaults
+INSERT OR IGNORE INTO settings (key, value) VALUES ('vulnerabilityScanEnabled', 'false');
+UPDATE settings
+SET value = 'false'
+WHERE key = 'vulnerabilityScanEnabled'
+ AND (value IS NULL OR TRIM(value) = '');
+
+INSERT OR IGNORE INTO settings (key, value) VALUES ('vulnerabilityScanInterval', '0 0 0 * * *');
+UPDATE settings
+SET value = '0 0 0 * * *'
+WHERE key = 'vulnerabilityScanInterval'
+ AND (value IS NULL OR TRIM(value) = '');
+
+-- Backfill missing auto-update excluded containers setting
+INSERT OR IGNORE INTO settings (key, value) VALUES ('autoUpdateExcludedContainers', '');
+UPDATE settings
+SET value = ''
+WHERE key = 'autoUpdateExcludedContainers'
+ AND value IS NULL;