From 344df5184ceaa1ba5503ec2431d458d5c75cf3f5 Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Sat, 27 Dec 2025 13:54:38 -0600 Subject: [PATCH] fix: Restore backup bug --- backend/src/features/backup/api/backup.controller.ts | 11 +++++++++-- docs/PROMPTS.md | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/src/features/backup/api/backup.controller.ts b/backend/src/features/backup/api/backup.controller.ts index 41c3cea..1af8e95 100644 --- a/backend/src/features/backup/api/backup.controller.ts +++ b/backend/src/features/backup/api/backup.controller.ts @@ -5,6 +5,7 @@ import { FastifyRequest, FastifyReply } from 'fastify'; import { Pool } from 'pg'; +import { logger } from '../../../core/logging/logger'; import { BackupService } from '../domain/backup.service'; import { BackupRestoreService } from '../domain/backup-restore.service'; import { @@ -192,7 +193,7 @@ export class BackupController { try { const result = await this.restoreService.executeRestore({ backupId: request.params.id, - createSafetyBackup: request.body.createSafetyBackup, + createSafetyBackup: request.body?.createSafetyBackup ?? true, }); if (result.success) { @@ -211,9 +212,15 @@ export class BackupController { }); } } catch (error) { + const errorMessage = error instanceof Error ? error.message : 'Failed to execute restore'; + logger.error('Restore execution failed', { + backupId: request.params.id, + error: errorMessage, + stack: error instanceof Error ? error.stack : undefined, + }); reply.status(400).send({ success: false, - error: error instanceof Error ? error.message : 'Failed to execute restore', + error: errorMessage, }); } } diff --git a/docs/PROMPTS.md b/docs/PROMPTS.md index 455f8d1..758b7ed 100644 --- a/docs/PROMPTS.md +++ b/docs/PROMPTS.md @@ -27,8 +27,8 @@ You are a senior software engineer specializsing in NodeJS, Typescript, front en *** CONTEXT *** - This is a modern web app for managing a vehicle fleet. It has both a desktop and mobile versions of the site that both need to maintain feature parity. It's currently deployed via docker compose but in the future will be deployed via k8s. - Read README.md CLAUDE.md and AI-INDEX.md and follow relevant instructions to understand this code repository in the context of this change. -- There is an error when you try and create a backup. -- Start with this file. /Users/egullickson/Documents/Technology/coding/motovaultpro/backend/src/features/admin/backup/api/backup.controller.ts +- There is an error when you try and restore a backup. +- Start with this file. /Users/egullickson/Documents/Technology/coding/motovaultpro/backend/src/features/backup/api/backup.controller.ts *** CHANGES TO IMPLEMENT *** - Research this code base and ask iterative questions to compile a complete plan.