fix(legacy_migration): graceful error handling for missing backup dirs (#6)#35
Open
zeroknowledge0x wants to merge 1 commit into
Open
Conversation
codeboost-tr#6) Fixes codeboost-tr#6 The migration script crashed with raw tracebacks when the backup directory was missing, unreadable, or contained a corrupt manifest. This commit replaces the broad 'except Exception' handlers with specific OSError subclasses (FileNotFoundError, PermissionError, OSError, json.JSONDecodeError) so the operator sees a clear, actionable error message instead of a Python stack trace. Changes: - _create_backup: separate handlers for FileNotFoundError (parent dir missing), PermissionError (no write access), and OSError (disk full / invalid path / etc.). - _restore_from_backup: precheck that backup_path exists and is a directory before attempting to read manifest; separate handlers for FileNotFoundError, PermissionError, json.JSONDecodeError, and OSError. - main(): migrate and rollback commands now return exit code 1 on failure so CI scripts and shell wrappers can detect backup errors without parsing tracebacks. Tests: 13 new tests covering create success/failure, restore success/failure (missing path, file-instead-of-dir, None, missing manifest, malformed manifest, permission error), exit code for migrate and rollback commands, and end-to-end rollback with a non-existent backup directory via subprocess. Total 43 tests pass.
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.
Automated PR from bounty executor shipper.
fix/issue-6-backup-error-handling