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: include missing catalog tables in runtime database health (#9746)

[._.]/ Adam Eivy8e689e20c5bb
diff --git a/server/routes/health.test.js b/server/routes/health.test.js
index eef84b9a4f..7ecde92a32 100644
--- a/server/routes/health.test.js
+++ b/server/routes/health.test.js
@@ -68,7 +68,7 @@ vi.mock('../services/cos.js', () => ({
}));
vi.mock('../lib/db.js', () => ({
- checkHealth: vi.fn().mockResolvedValue({ connected: false, hasSchema: false })
+ checkHealth: vi.fn().mockResolvedValue({ connected: false, hasSchema: false, hasCatalogSchema: false })
}));
// The build stamp is read from the checkout the suite happens to run in, so
@@ -159,6 +159,42 @@ describe('System Health Routes', () => {
expect(response.body).toHaveProperty('overallHealth');
});
+ it('warns when connected=true, hasSchema=true but hasCatalogSchema=false', async () => {
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true, hasCatalogSchema: false });
+ const response = await request(app).get('/api/system/health/details');
+
+ expect(response.status).toBe(200);
+ expect(response.body.overallHealth).toBe('warning');
+ expect(response.body.warnings).toContainEqual({
+ type: 'database',
+ severity: 'warning',
+ message: 'PostgreSQL connected and schema available but Catalog tables missing — open Settings → Database to troubleshoot'
+ });
+ });
+
+ it('recovers from catalog-only schema failure when hasCatalogSchema is restored', async () => {
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true, hasCatalogSchema: false });
+ const failed = await request(app).get('/api/system/health/details');
+ expect(failed.body.overallHealth).toBe('warning');
+ const warnings = failed.body.warnings.filter(w => w.type === 'database');
+ expect(warnings).toHaveLength(1);
+ expect(warnings[0].message).toContain('Catalog tables missing');
+
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true, hasCatalogSchema: true });
+ const recovered = await request(app).get('/api/system/health/details');
+ expect(recovered.body.overallHealth).toBe('healthy');
+ expect((recovered.body.warnings || []).filter(w => w.type === 'database')).toHaveLength(0);
+ });
+
+ it('handles backward compatibility when hasCatalogSchema is omitted (undefined)', async () => {
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true });
+ const response = await request(app).get('/api/system/health/details');
+
+ expect(response.status).toBe(200);
+ expect(response.body.overallHealth).toBe('healthy');
+ expect((response.body.warnings || []).filter(w => w.type === 'database')).toHaveLength(0);
+ });
+
it('reports an unreadable app aggregate without leaking details, then recovers to a healthy empty registry', async () => {
const privateDetail = 'EIO reading /private/example-registry.json';
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
diff --git a/server/services/systemHealthSnapshot.js b/server/services/systemHealthSnapshot.js
index 8df8cf8d17..f3b96425f2 100644
--- a/server/services/systemHealthSnapshot.js
+++ b/server/services/systemHealthSnapshot.js
@@ -235,6 +235,8 @@ export async function getSystemHealthSnapshot() {
rawWarnings.push({ type: 'database', severity: 'warning', message: `PostgreSQL disconnected${dbHealth.error ? `: ${dbHealth.error}` : ''}` });
} else if (!dbHealth.hasSchema) {
rawWarnings.push({ type: 'database', severity: 'warning', message: 'PostgreSQL connected but schema missing' });
+ } else if (dbHealth.hasCatalogSchema === false) {
+ rawWarnings.push({ type: 'database', severity: 'warning', message: 'PostgreSQL connected and schema available but Catalog tables missing — open Settings → Database to troubleshoot' });
}
// A `gh` that cannot reach the forge does not fail loudly anywhere else: the