Skip to content

Context parameter do not work correctly inside a profiles object #555

@philip-tsoi-hklttl

Description

@philip-tsoi-hklttl

Do you read the FAQ?

Describe the bug
The context parameters for specifying a local synchronization folder are not working correctly when placed inside a profiles object. When a profile is activated, the extension either ignores the specified local folder and uploads the entire workspace, or it uploads the local folder itself as a sub-folder to the remote path, resulting in an incorrect file structure on the server. The same configuration works perfectly when placed in a single-profile sftp.json file at the root level.

This bug prevents the use of multiple profiles for projects that require a specific local subfolder to be synchronized to a distinct remote path.

To be concise, this works by copying the files and subfolders in my local /API folder to the server's /var/www/dev-api
{
"name": "XXX",
"protocol": "sftp",
"port": 22,
"defaultProfile": "dev-api",
"ignore": ["**/node_modules"],
"remotePath": "/var/www/dev-api",
"context": "API",
"uploadOnSave": true
}

But this setting will copy my local /API folder to the server's /var/www/dev-api/API
(by creating a new folder), which is not what expected

{
"name": "XXX",
"protocol": "sftp",
"port": 22,
"defaultProfile": "dev-api",
"profiles": {
"dev-api": {
"ignore": ["**/node_modules"],
"remotePath": "/var/www/dev-api",
"context": "API",
"uploadOnSave": true
},
"dev-app": {
"remotePath": "/var/www/dev-app",
"context": "APP/build",
"uploadOnSave": false
}
}
}

To Reproduce
Steps to reproduce the behavior:

  1. Create a sftp.json file in the .vscode folder of your workspace with a profiles configuration. The configuration should include at least one profile that uses the context or mappings parameter to specify a local subfolder (e.g., API).
  2. Make sure this profile is either the defaultProfile or use the SFTP: Set profile command to activate it.
  3. Make a change to a file inside the local API folder.
  4. The uploadOnSave feature is enabled and triggers an upload, or you manually run a command like SFTP: Upload Folder.
  5. See that the uploaded file is placed in an incorrect remote path, such as /remote/path/API/file.js, instead of the expected /remote/path/file.js.

Expected behavior
When a profile with a context parameter is active, the contents of the specified local folder should be uploaded to the remotePath without creating an additional subfolder. For example, a local file at [workspace]/API/file.js should be uploaded to the remote path [remotePath]/file.js.

Screenshots
A screenshot of the local file explorer showing the API subfolder and its contents.
A second screenshot of the remote file structure after an upload, showing the incorrect path .../dev-api/API/file.js instead of the correct .../dev-api/file.js.

Desktop (please complete the following information):

  • OS: Windows 11 24H2
  • VSCode Version: 1.103.1
  • Extension Version: 1.16.3

Extension Logs from Startup - required
To provide the necessary logs, please follow the steps below:

  1. Open VS Code User Settings.
  2. Set sftp.debug to true.
  3. Reload the VS Code window.
  4. Reproduce the problem by performing an upload with the profile active.
  5. Go to View > Output and select sftp from the dropdown menu to copy the logs.
    I will update this section with the relevant logs once I have them.

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