Conversation
…hen DevicePassCmd fails When DevicePassCmd fails (e.g. incorrect password reference), the previous code wrapped the error in sdm.DeviceDecryptionError, which was misleading because no decryption was ever attempted. - Add DevicePassCmdError exception to device_managers.py - Add open_encrypted_device wrapper that separates pass_cmd execution from cryptsetup, raising DevicePassCmdError on pass_cmd failure - Add decrypted_device context manager wrapper using the new function - Update cli.py to use the new wrappers instead of sdm.open_encrypted_device and sdm.decrypted_device - Add tests verifying the correct exception type is raised in each case Agent-Logs-Url: https://github.com/MaxG87/ButterBackup/sessions/c09c185a-8901-460d-acbc-8519ba60daa0 Co-authored-by: MaxG87 <5477952+MaxG87@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
MaxG87
April 26, 2026 10:28
View session
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.
Fixes #93.
Problem
When
DevicePassCmdfails to execute (e.g. because the password reference is incorrect), the error was wrapped insdm.DeviceDecryptionError. This is misleading because no decryption was ever attempted — the password command itself failed beforecryptsetupwas even invoked.Solution
Added a new
DevicePassCmdErrorexception and two wrapper functions indevice_managers.pythat separate the execution of the password command from the actual cryptsetup decryption:open_encrypted_device: runs thepass_cmdfirst in isolation. If it fails, raisesDevicePassCmdError. If it succeeds, pipes the password tocryptsetup; if that fails, raisessdm.DeviceDecryptionError.decrypted_device: context manager using the above function.cli.pyis updated to use these wrappers instead of calling thestorage_device_managersfunctions directly.Changes
src/butter_backup/device_managers.py: addDevicePassCmdError,open_encrypted_device, anddecrypted_devicesrc/butter_backup/cli.py: use the new wrappers fromdevice_managerstests/test_device_managers.py: new test file verifying that:DevicePassCmdraisesDevicePassCmdError(notDeviceDecryptionError)DeviceDecryptionError