Skip to content

fix(transfer): handle LOGICAL root home directory mapping#557

Merged
Nahuel990 merged 3 commits intoministackorg:mainfrom
stefanmb:fix/sftp-logical-root-entry
May 4, 2026
Merged

fix(transfer): handle LOGICAL root home directory mapping#557
Nahuel990 merged 3 commits intoministackorg:mainfrom
stefanmb:fix/sftp-logical-root-entry

Conversation

@stefanmb
Copy link
Copy Markdown
Contributor

@stefanmb stefanmb commented May 4, 2026

Summary

Fix SFTP LOGICAL home directory mappings when the mapping entry is /.

Previously, a root mapping did not match normal SFTP paths because the resolver built the match prefix as entry + "/". For Entry="/", that produced "//", so paths like /users.csv failed to match the configured mapping and fell through to the unmapped fallback behavior.

This change treats / as its own prefix while preserving the existing behavior for non-root mappings.

Examples

Given this Transfer user configuration:

{
  "HomeDirectoryType": "LOGICAL",
  "HomeDirectoryMappings": [
    {
      "Entry": "/",
      "Target": "/my-sftp-bucket"
    }
  ]
}

Expected behavior:

SFTP path S3 target
/users.csv s3://my-sftp-bucket/users.csv
/reports/may.csv s3://my-sftp-bucket/reports/may.csv
/ s3://my-sftp-bucket/

Before this fix, /users.csv did not match the / entry because the code checked for a "//" prefix.

Non-root mappings still behave the same:

{
  "HomeDirectoryType": "LOGICAL",
  "HomeDirectoryMappings": [
    {
      "Entry": "/inbox",
      "Target": "/my-sftp-bucket/incoming"
    }
  ]
}
SFTP path S3 target
/inbox/today.csv s3://my-sftp-bucket/incoming/today.csv

Longest-prefix matching is preserved when root and more specific mappings are combined:

{
  "HomeDirectoryType": "LOGICAL",
  "HomeDirectoryMappings": [
    {
      "Entry": "/",
      "Target": "/my-sftp-bucket/root"
    },
    {
      "Entry": "/inbox",
      "Target": "/my-sftp-bucket/incoming"
    }
  ]
}
SFTP path S3 target
/inbox/today.csv s3://my-sftp-bucket/incoming/today.csv
/other/file.csv s3://my-sftp-bucket/root/other/file.csv

Testing

Added an end-to-end regression test which:

  1. Creates a Transfer user with HomeDirectoryType="LOGICAL" and Entry="/".
  2. Uploads /users.csv through SFTP.
  3. Reads the same file back through SFTP.
  4. Verifies the object exists in S3 at users.csv.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Docker image for this PR has been published: ministackorg/ministack-preview-build:pr-557-9ca343f0

@stefanmb stefanmb marked this pull request as ready for review May 4, 2026 18:20
Updated changelog to reflect changes in Transfer Family logical root home directory mappings and other fixes.
@Nahuel990
Copy link
Copy Markdown
Collaborator

Thanks for this fix @stefanmb !

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Docker image for this PR has been published: ministackorg/ministack-preview-build:pr-557-d2b9416f

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Docker image for this PR has been published: ministackorg/ministack-preview-build:pr-557-aff37d22

@Nahuel990 Nahuel990 merged commit 203997e into ministackorg:main May 4, 2026
2 checks passed
YakirOren pushed a commit to YakirOren/ministack that referenced this pull request May 5, 2026
…rg#557)

* fix(transfer): handle LOGICAL root home directory mapping

* Update CHANGELOG.md for version 1.3.26

Updated changelog to reflect changes in Transfer Family logical root home directory mappings and other fixes.
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