Skip to content

asyncssh.sftp.SFTPBadMessage: Unable to decode name #610

@ttomasz

Description

@ttomasz

I'm getting the following error when trying to list contents of a directory:

File "/home/xxx/venv/lib/python3.10/site-packages/sshfs/spec.py", line 204, in _ls
    file_attrs = await channel.readdir(path)
  File "/home/xxx/venv/lib/python3.10/site-packages/asyncssh/sftp.py", line 5098, in readdir
    return [entry async for entry in self.scandir(path)]
  File "/home/xxx/venv/lib/python3.10/site-packages/asyncssh/sftp.py", line 5098, in <listcomp>
    return [entry async for entry in self.scandir(path)]
  File "/home/xxx/venv/lib/python3.10/site-packages/asyncssh/sftp.py", line 5067, in scandir
    self.decode(cast(bytes, entry.filename))
  File "/home/xxx/venv/lib/python3.10/site-packages/asyncssh/sftp.py", line 3528, in decode
    raise SFTPBadMessage('Unable to decode name') from None
asyncssh.sftp.SFTPBadMessage: Unable to decode name

(I'm actually using sshfs library but this part of stack suggests error is coming from this library)

upon checking the file paths with lftp cli tool I see that some paths are garbage e.g.:

drwxr-xr-x    3 1002     1005     25210880 Nov 13 20:45 .
drwxr-xr-x    7 root     root         4096 Feb 22  2022 ..
drwx------    2 1002     1005         4096 Mar 26  2023 .cache
-rw-r--r--    1 root     root         7421 Nov 13 20:45 00000770_2303241948.##$$ã<8b>°+ót°+^D<89>°+ðæ^A^
-rw-r--r--    1 root     root        56697 Sep  9  2022 00001020_2209040017.xml
-rw-r--r--    1 root     root         1825 Sep  9  2022 00001020_2209040019.xml
-rw-r--r--    1 root     root         4029 Sep  9  2022 00001020_2209040121.xml
...
-rw-r--r--    1 root     root         9414 Dec 11  2022 00001113_2212111945.xml
-rw-r--r--    1 root     root          340 Jan 17  2023 00001113_2212112052.<8d><8d>ð2¿á(+8Ì(+¬á(+ÿ<^Gÿ
-rw-r--r--    1 root     root         6661 Dec 11  2022 00001113_2212112054.xml

It would be nice however if that could be gracefully handled. CLI tools like sftp and lftp deal with it somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions