Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Paramiko size mismatch errors in utf-8 strings #997

Closed
wants to merge 3 commits into from

Conversation

sbj-ss
Copy link

@sbj-ss sbj-ss commented Aug 8, 2023

Length of unicode strings consisting of multibyte characters differs from their size in bytes. Hence uploads of files and templates using unicode characters will fail with messages like

    Failed to upload file, retrying: size mismatch in put!  208 != 190
    Failed to upload file, retrying: size mismatch in put!  208 != 190
    Failed to upload file, retrying: size mismatch in put!  208 != 190
    [172.33.2.57] Command socket/SSH error: OSError('size mismatch in put!  208 != 190',)
    [172.33.2.57] Error: executed 0/1 commands

Using BytesIO will prevent this.

Copy link
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbj-ss thank you for the PR, this definitely seems sensible to me! I’ll fix up those test issues as they’re hidden in some of the legacy test stuff and get this merged!

@Fizzadar
Copy link
Member

As part of the v3 work I incorporated this change at a lower level which I think better handles these cases automatically:

Usually I hate implicit behavior (lots of v3 work removes it!) but in this case I think this is best since passing StringIO objects in/out of operations is standard and recommended. This ensures that the output file always matches what is requested in get_file_io. Thank you once again for the PR, inspiration and fix @sbj-ss!

@Fizzadar Fizzadar closed this Jan 13, 2024
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.

2 participants