Skip to content

fix(legacy_migration): graceful error handling for missing backup dirs (#6)#35

Open
zeroknowledge0x wants to merge 1 commit into
codeboost-tr:mainfrom
zeroknowledge0x:fix/issue-6-backup-error-handling
Open

fix(legacy_migration): graceful error handling for missing backup dirs (#6)#35
zeroknowledge0x wants to merge 1 commit into
codeboost-tr:mainfrom
zeroknowledge0x:fix/issue-6-backup-error-handling

Conversation

@zeroknowledge0x

Copy link
Copy Markdown

Automated PR from bounty executor shipper.

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.
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.

1 participant