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

Return a client error when backup destination is missing (#11651)

[._.]/a60fe0748337
diff --git a/server/routes/backup.js b/server/routes/backup.js
index 464188cc97..0c4a09f98c 100644
--- a/server/routes/backup.js
+++ b/server/routes/backup.js
@@ -89,7 +89,11 @@ router.delete('/snapshots/:snapshotId', asyncHandler(async (req, res) => {
router.post('/restore', asyncHandler(async (req, res) => {
const { snapshotId, source, subdirFilter, dryRun } = validateRequest(restoreRequestSchema, req.body);
const settings = await getSettings();
- const result = await backup.restoreSnapshot(settings.backup?.destPath, snapshotId, {
+ const destPath = settings.backup?.destPath;
+ if (!destPath) {
+ throw new ServerError('No backup destination configured in settings', { status: 400, code: 'BACKUP_NOT_CONFIGURED' });
+ }
+ const result = await backup.restoreSnapshot(destPath, snapshotId, {
dryRun,
subdirFilter,
...(source ? { source } : {}),
diff --git a/server/routes/backup.test.js b/server/routes/backup.test.js
index 6236afb1ac..3f9504f200 100644
--- a/server/routes/backup.test.js
+++ b/server/routes/backup.test.js
@@ -320,6 +320,27 @@ describe('backup routes', () => {
});
describe('POST /api/backup/restore', () => {
+ it.each([
+ { description: 'missing backup settings', settings: {}, dryRun: true },
+ { description: 'missing backup settings', settings: {}, dryRun: false },
+ { description: 'missing destination', settings: { backup: {} }, dryRun: true },
+ { description: 'missing destination', settings: { backup: {} }, dryRun: false },
+ { description: 'empty destination', settings: { backup: { destPath: '' } }, dryRun: true },
+ { description: 'empty destination', settings: { backup: { destPath: '' } }, dryRun: false },
+ ])('returns a structured 400 without invoking restore for $description (dryRun=$dryRun)', async ({ settings, dryRun }) => {
+ getSettings.mockResolvedValue(settings);
+ const res = await request(buildApp())
+ .post('/api/backup/restore')
+ .send({ snapshotId: 'snap-1', dryRun });
+
+ expect(res.status).toBe(400);
+ expect(res.body).toMatchObject({
+ error: 'No backup destination configured in settings',
+ code: 'BACKUP_NOT_CONFIGURED',
+ });
+ expect(backup.restoreSnapshot).not.toHaveBeenCalled();
+ });
+
it('returns 400 when snapshotId is missing', async () => {
getSettings.mockResolvedValue({ backup: { destPath: '/dest' } });
const res = await request(buildApp()).post('/api/backup/restore').send({});