rokadepiyush49-rgb opened a new pull request, #77514: URL: https://github.com/apache/airflow/pull/77514
closes: #77513 With `s3_filenames="*"`, `S3ToSFTPOperator` and `S3ToFTPOperator` transfer every key that `list_keys` returns. Folders created in the S3 console are stored as empty objects whose key ends in `/`. The operators tried to store those as files at a directory path, and the server rejected them (`550 Is a directory.` on FTP). S3 lists keys in sorted order, so the marker of `s3_key` itself comes first, and the task failed before any file was moved. Both operators now skip keys ending in `/` right after listing, and log them at info level (the first ten, then a count, like the existing prefix warning). This also keeps markers out of the warning about files a string prefix did not select. A one-line note is added to the `s3_filenames` docstring. #76408 fixed the same problem in `S3ToAzureBlobStorageOperator` with `strip_overlapping_folder_markers`. That helper keeps a marker that no other key overlaps (e.g. `empty/`), which is right for object stores, but not for SFTP/FTP, where a file cannot have a path ending in `/`. So these operators skip every marker. Not changed: an explicit list (`s3_filenames=[...]`) and single-file mode, where nothing is listed. Neither operator creates remote directories, so nested keys still need the destination subdirectory to exist; that is existing behavior, noted in the issue. **Testing** - Added `test_execute_skips_folder_marker_keys` to both test modules, covering `"*"` (markers for `s3_key`, a nested folder and an empty folder) and a string prefix. All 4 cases fail on `main` and pass with this change. - `test_s3_to_ftp.py` and `TestS3ToSFTPOperatorInit`: 29 passed. The SSH-server tests in `TestS3ToSFTPOperator` need a local sshd and were left to CI. - Reproduced end to end with moto S3 and a local FTP server: before, `ftplib.error_perm: 550 Is a directory.`; after, `Skipping 1 S3 folder-marker key(s), which have no file to transfer: ['reports/']` and `jan.csv` is stored. - `prek run` on the changed files: all hooks passed. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
