Repository navigation
Conversation
Frappe deletes old files in private/backups before each backup. If a folder is in private/backups, os.remove raises IsADirectoryError and the backup fails. The team saw only "Job Failure" and did not know the cause, because a custom app or a script made the folder. The banner on the failed job now names the folder and tells the team to remove it. It has no Help link, because no doc page covers this error. The real fix is in frappe (skip folders), but sites on older versions continue to fail until then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7998 +/- ##
===========================================
+ Coverage 67.00% 67.08% +0.08%
===========================================
Files 1178 1178
Lines 118284 118551 +267
Branches 2383 2379 -4
===========================================
+ Hits 79256 79535 +279
+ Misses 38961 38949 -12
Partials 67 67
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A "Backup Site" job fails when the
private/backupsfolder of a site contains a folder. Before each backup, Frappe deletes old files inprivate/backups. Frappe usesos.remove, which cannot delete a folder, so the backup stops with this error:The customer sees only the raw traceback in the job. The traceback does not tell the customer what to do. Usually a custom app or a script of the customer makes the folder, so only the customer can remove it.
Change
This PR adds a handler to
agent_job_notifications.py. The handler starts when the traceback or the output of the job containsIsADirectoryErrorand/private/backups/. The failed job page then shows a red banner. The "Fix" button on the banner opens a dialog that tells the customer to do these steps:private/backups, or move them to a different location.The dialog shows the path of the folder from the traceback. The dialog has no Help link, because no page on docs.frappe.io covers this error.
A fix in Frappe (skip folders in
delete_temp_backups) can prevent the failure. But sites on older Frappe versions continue to fail until they update, so this banner is still necessary.Screenshots
The screenshots show a failed "Backup Site" job on a local demo site. The job went through the real failure path,
send_job_failure_notification, once with the code fromdevelopand once with the code from this PR.Tests
test_folder_in_backups_folder_names_the_folder_to_delete: the banner is actionable and shows the path of the folder.test_folder_error_outside_backups_folder_is_not_actionable: anIsADirectoryErrorfor a different folder gets no banner.I did these checks:
bench backupon a local site with a folder inprivate/backups. The backup failed atdelete_temp_backups, line 662, as in the example job.test_agent_job. 39 of 41 tests pass. The 2 tests that fail aretest_fail_old_jobs_*. They also fail ondeveloplocally, because the local database does not have their sites.test_site_backup. All 13 tests pass.🤖 Generated with Claude Code