Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 2, 2025

When restoring a project from backup, schedules were being duplicated due to two separate creation paths:

  1. Template restore automatically creates schedules for templates with cron settings
  2. Explicit schedule restore processes schedules from the backup's Schedules array

This resulted in duplicate schedules with identical data but different IDs, and the makeUniqueNames() function would generate arbitrary random names for the duplicates.

Root Cause

The issue occurred because:

  • BackupSchedule was missing the required GetName() method from the BackupEntry interface
  • BackupTemplate.Restore() unconditionally created schedules for templates with cron fields
  • The main restore process also restored explicit schedules, creating duplicates

Solution

  1. Added missing GetName() method for BackupSchedule to satisfy the BackupEntry interface
  2. Modified template restore logic to detect when explicit schedules exist in the backup and skip automatic schedule creation
  3. Maintained backward compatibility by adding RestoreWithScheduleHandling() method while preserving the original Restore() behavior
  4. Added comprehensive test that verifies only one schedule is created instead of duplicates

The fix ensures that when both template cron settings and explicit schedules exist in a backup, only the explicit schedule is restored with its proper name, preventing duplication and random naming.

Fixes #3172


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@fiftin
Copy link
Collaborator

fiftin commented Sep 3, 2025

@copilot try again

- Add missing GetName() method for BackupSchedule
- Modify template restore to skip automatic schedule creation when explicit schedules exist
- Add test to verify fix prevents duplicate schedules
- Maintain backward compatibility with RestoreWithScheduleHandling method

Fixes #3172

Co-authored-by: fiftin <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot try again

I've successfully implemented the fix for the schedule duplication issue. The solution addresses the root cause by:

  1. Added missing GetName() method for BackupSchedule (required by the BackupEntry interface)
  2. Modified template restore logic to skip automatic schedule creation when explicit schedules are present in the backup
  3. Added comprehensive test that verifies only one schedule is created instead of duplicates

The fix ensures that when restoring a project, schedules aren't duplicated between template cron settings and explicit schedule entries. The test confirms that exactly one schedule with the correct explicit name is restored, preventing the arbitrary random names mentioned in the issue.

Commit: 34cfbe8

@Copilot Copilot AI changed the title [WIP] Problem: Restoring a project introduces hidden 'schedule' objects with arbitrary names Fix schedule duplication issue in backup/restore functionality Sep 3, 2025
Copilot finished work on behalf of fiftin September 3, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: Restoring a project introduces hidden 'schedule' objects with arbitrary names
2 participants