SFTP put_file passes full destination URLs to Paramiko

Open Beginner friendly
#2,443 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@IlyaKhalafi is already working on this.

Since Nov 6, 2026.

  • #2444 by @IlyaKhalafi — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in the SFTPFileSystem.put_file implementation in fsspec/implementations/sftp.py and compare how it normalizes the destination for makedirs with the path passed to Paramiko.put. Check the SFTP tests for existing URL and ssh alias coverage, then add or update cases to verify both forms send the normalized remote path. Done when file transfer and parent creation use the same normalized destination.

Written by the indexing model from the issue text.

Description

Found while reviewing remote upload paths. SFTPFileSystem.put_file normalizes the destination parent through makedirs, but then passes the original full URL to Paramiko.put as the remote filename.

Reproduced on current master, Python 3.12 and Paramiko 5.1.0 with a filesystem-backed transport double. Other public SFTP methods already strip the protocol.

from unittest.mock import patch, Mock
from fsspec.implementations.sftp import SFTPFileSystem

with patch.object(SFTPFileSystem, "_connect"):
    fs = SFTPFileSystem(host="host", skip_instance_cache=True)
    fs.ftp = Mock()
    fs.mkdirs = Mock()
    fs.put_file("source.txt", "sftp://host/parent/target.txt")
    print(fs.ftp.put.call_args)

The destination sent to Paramiko is sftp://host/parent/target.txt rather than /parent/target.txt. The ssh alias has the same problem. A server then interprets the URL as a literal relative path and the upload fails, despite the correct parent having been created.

Expected the same normalized destination for parent creation and file transfer.

Dominant language
Python
Stars
1.4k
Forks
577
Avg merge
2d 36m
Merged PRs (30d)
51

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fsspec/filesystem_spec

All issues in fsspec/filesystem_spec

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.