From 1394b47570d03358e71170428d16f625f8bb8258 Mon Sep 17 00:00:00 2001 From: Rostislav Dugin Date: Tue, 17 Mar 2026 14:55:16 +0300 Subject: [PATCH 1/2] FIX (agent): Fix linting issues --- agent/internal/features/start/daemon.go | 3 ++- agent/internal/features/start/lock.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/internal/features/start/daemon.go b/agent/internal/features/start/daemon.go index 15e6a5d..c1931aa 100644 --- a/agent/internal/features/start/daemon.go +++ b/agent/internal/features/start/daemon.go @@ -3,6 +3,7 @@ package start import ( + "context" "errors" "fmt" "log/slog" @@ -93,7 +94,7 @@ func spawnDaemon(log *slog.Logger) (int, error) { return 0, fmt.Errorf("failed to get working directory: %w", err) } - cmd := exec.Command(execPath, args...) + cmd := exec.CommandContext(context.Background(), execPath, args...) cmd.Dir = cwd cmd.Stderr = logFile cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} diff --git a/agent/internal/features/start/lock.go b/agent/internal/features/start/lock.go index 58a0d10..02036dd 100644 --- a/agent/internal/features/start/lock.go +++ b/agent/internal/features/start/lock.go @@ -42,10 +42,10 @@ func AcquireLock(log *slog.Logger) (*os.File, error) { _ = f.Close() if pidErr != nil { - return nil, fmt.Errorf("Another instance is already running.") + return nil, fmt.Errorf("another instance is already running") } - return nil, fmt.Errorf("Another instance is already running (PID %d).", pid) + return nil, fmt.Errorf("another instance is already running (PID %d)", pid) } func ReleaseLock(f *os.File) { @@ -59,7 +59,7 @@ func ReadLockFilePID() (int, error) { if err != nil { return 0, err } - defer f.Close() + defer func() { _ = f.Close() }() return readLockPID(f) } From 0d7e147df65a0d06250b80749ef60097cc692255 Mon Sep 17 00:00:00 2001 From: Rostislav Dugin Date: Tue, 17 Mar 2026 16:33:00 +0300 Subject: [PATCH 2/2] FIX (wal): Allow to save error via /complete endpoint --- .../backups/controllers/postgres_wal_controller.go | 8 ++++++++ backend/internal/features/backups/backups/dto/dto.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go b/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go index 5888651..c18f254 100644 --- a/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go +++ b/backend/internal/features/backups/backups/controllers/postgres_wal_controller.go @@ -222,6 +222,14 @@ func (c *PostgreWalBackupController) CompleteFullBackupUpload(ctx *gin.Context) return } + if request.Error == nil && (request.StartSegment == "" || request.StopSegment == "") { + ctx.JSON( + http.StatusBadRequest, + gin.H{"error": "startSegment and stopSegment are required when no error is provided"}, + ) + return + } + if err := c.walService.FinalizeBasebackup( database, request.BackupID, diff --git a/backend/internal/features/backups/backups/dto/dto.go b/backend/internal/features/backups/backups/dto/dto.go index bd969c0..fa5564c 100644 --- a/backend/internal/features/backups/backups/dto/dto.go +++ b/backend/internal/features/backups/backups/dto/dto.go @@ -84,7 +84,7 @@ type UploadBasebackupResponse struct { type FinalizeBasebackupRequest struct { BackupID uuid.UUID `json:"backupId" binding:"required"` - StartSegment string `json:"startSegment" binding:"required"` - StopSegment string `json:"stopSegment" binding:"required"` + StartSegment string `json:"startSegment"` + StopSegment string `json:"stopSegment"` Error *string `json:"error"` }