Skip to content

Conversation

@fabi200123
Copy link
Contributor

Fix UnicodeDecodeError with non-UTF-8 filenames in SSH operations

This PR fixes a critical bug where migrations fail with UnicodeDecodeError
when source systems contain files or directories with non-UTF-8 characters in
their names.

The fix centralizes UTF-8 decoding with error handling in exec_ssh_cmd(),
which now returns decoded strings with errors='replace' instead of raw bytes.
Invalid UTF-8 sequences are replaced with the character, allowing migrations
to continue while logging warnings for monitoring.

Changes:

  • Modified exec_ssh_cmd() to return strings with safe decoding
  • Added SFTP fallback in list_ssh_dir() for encoding errors
  • Removed all .decode() calls on command execution results (15 locations)
  • Updated test expectations to match new return type
  • Preserved SFTP file reading operations (still return bytes)

Impact:

  • Prevents migration failures on systems with non-UTF-8 filenames
  • No breaking changes to external APIs
  • Minimal performance overhead
  • Backward compatible (except test mocks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants