Do not throw exception when trying to delete a failed backup#2458
Do not throw exception when trying to delete a failed backup#2458Boy132 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesBackup deletion handling
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/Services/Backups/DeleteBackupService.php`:
- Around line 38-42: Update the exception handling in DeleteBackupService around
deleteBackup so adapter failures are only swallowed for backups that never
started uploading. Require the backup to lack upload metadata, such as
upload_id, before allowing the row deletion fallback; otherwise rethrow the
exception to preserve cleanup or retry handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0afeed2f-737a-46a1-ac5c-90559e754fb8
📒 Files selected for processing (1)
app/Services/Backups/DeleteBackupService.php
| try { | ||
| $schema->deleteBackup($backup); | ||
| } catch (Exception $exception) { | ||
| throw_if($backup->is_successful, $exception); | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## Files\n'
git ls-files | rg 'app/Services/Backups/DeleteBackupService.php|app/Models/Backup.php|app/Services/Backups|app/Models'
printf '\n## Outline: DeleteBackupService\n'
ast-grep outline app/Services/Backups/DeleteBackupService.php --view expanded || true
printf '\n## Outline: Backup model\n'
ast-grep outline app/Models/Backup.php --view expanded || true
printf '\n## Relevant text search\n'
rg -n "is_successful|upload_id|deleteBackup|multipart|S3BackupSchema|successful|upload" app/Services/Backups app/Models -SRepository: pelican-dev/panel
Length of output: 4782
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## DeleteBackupService\n'
cat -n app/Services/Backups/DeleteBackupService.php
printf '\n## InitiateBackupService (relevant section)\n'
sed -n '1,180p' app/Services/Backups/InitiateBackupService.php | cat -n
printf '\n## Backup model (relevant section)\n'
sed -n '1,180p' app/Models/Backup.php | cat -n
printf '\n## Upload ID usage across repo\n'
rg -n "upload_id|multipart|completeMultipart|abortMultipart|is_successful|completed_at" app -S
printf '\n## Backup adapter/schema classes\n'
fd -a "BackupAdapterService.php|S3BackupSchema.php|*BackupSchema.php" appRepository: pelican-dev/panel
Length of output: 19578
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## S3BackupSchema::deleteBackup and multipart flow\n'
sed -n '1,260p' app/Extensions/BackupAdapter/Schemas/S3BackupSchema.php | cat -n
printf '\n## BackupRemoteUploadController\n'
sed -n '1,220p' app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php | cat -n
printf '\n## BackupStatusController\n'
sed -n '1,160p' app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php | cat -n
printf '\n## PruneOrphanedBackupsCommand\n'
sed -n '1,160p' app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php | cat -n
printf '\n## BackupQueryBuilder\n'
sed -n '1,120p' app/Eloquent/BackupQueryBuilder.php | cat -nRepository: pelican-dev/panel
Length of output: 19646
Do not swallow adapter failures for in-progress backups.
is_successful === false also covers backups that already have upload_id set, so deleting the row after a failed deleteBackup() can leave multipart uploads or objects orphaned. Restrict this fallback to records that never started uploading, or keep cleanup metadata for a retry.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/Services/Backups/DeleteBackupService.php` around lines 38 - 42, Update
the exception handling in DeleteBackupService around deleteBackup so adapter
failures are only swallowed for backups that never started uploading. Require
the backup to lack upload metadata, such as upload_id, before allowing the row
deletion fallback; otherwise rethrow the exception to preserve cleanup or retry
handling.
Closes #2457