Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: refuse cutover preflight without saved configuration (#8849)

[._.]/ Adam Eivy6440af5ae2b3
diff --git a/server/routes/databasePreflight.test.js b/server/routes/databasePreflight.test.js
index 7bb66bb74c..7ac73ef9f6 100644
--- a/server/routes/databasePreflight.test.js
+++ b/server/routes/databasePreflight.test.js
@@ -153,6 +153,15 @@ describe('database maintenance preflight HTTP contract', () => {
rmSync(join(PATHS.installRoot, '.env'), { recursive: true });
});
+ it('refuses missing saved configuration rather than assuming the default direction', async () => {
+ rmSync(join(PATHS.installRoot, '.env'));
+ POOL_CONFIG.port = 5561;
+ const result = await preflight({ source: 'docker', target: 'native' });
+ expect(result.status).toBe(409);
+ expect(result.body.code).toBe('DATABASE_PREFLIGHT_UNTRUSTED');
+ expect(getSystemActivity).not.toHaveBeenCalled();
+ });
+
it('re-reads saved settings after asynchronous work inspection', async () => {
getSystemActivity.mockImplementation(async () => { saveMode('docker'); return idle(); });
expect((await preflight()).body.code).toBe('DATABASE_PREFLIGHT_STALE');
diff --git a/server/services/databasePreflight.js b/server/services/databasePreflight.js
index d4101d07bc..d73b805aed 100644
--- a/server/services/databasePreflight.js
+++ b/server/services/databasePreflight.js
@@ -37,10 +37,7 @@ function readConfiguration() {
// a failed .env read, which cannot be treated as evidence for a cutover.
const envPath = join(PATHS.installRoot, '.env');
let content;
- try { content = readFileSync(envPath, 'utf8'); } catch (err) {
- if (err.code !== 'ENOENT') throw unavailable();
- content = null;
- }
+ try { content = readFileSync(envPath, 'utf8'); } catch { throw unavailable(); }
const configPath = join(PATHS.installRoot, 'ecosystem.config.cjs');
let configuration;
try {