Repository navigation
Conversation
aaron-y-chen
left a comment
There was a problem hiding this comment.
Question about move_object=True: a skipped key never reaches _copy_single_object, so it is not deleted either.
-
Run 1 - listing
["folder/", "folder/file.txt"]folder/is skipped,folder/file.txtis moved, the bucket keepsfolder/.
-
Run 2 - listing
["folder/"]- no overlap now, so it is kept and copied to
<dest>/folder, the path run 1 created as a directory.
- no overlap now, so it is kept and copied to
What is the intended outcome for run 2 here?
|
Thanks for working through that sequence. There was not one. The rule keeps any trailing-slash key it cannot prove is a marker, which came from the S3/GCS operators where that is always safe. On SFTP a path cannot be both a file and a directory, so that no longer holds. I reproduced it against a real bucket and SFTP server, and run 2 fails on every run from then on. Pushed a follow-up commit that makes the intent explicit. A trailing-slash key is also skipped when its destination is already a directory, so run 2 becomes a no-op. It only fires where the write would have failed anyway, so nothing transferable is dropped. |
|
Thank you for submitting the PR, addressing real problem. I think the behaviour of "stmth/" -> "dst/smth"(file) is a side effect of the The "name/" should always mean a folder, so we should create a folder on dst or do no-op in any case. I think it makes sense to make additional parameter in a style "mind empty dirs" with default "False" value and and handle that. And if we don't mind empty dir we'd probably do not delete with move object command(?). Should also lead to least corner cases to handle. WDYT? @yuseok89 |
|
Thanks, this makes sense. I checked it against a real SFTP server, and you're right that writing name/ as a file only comes from the This PR set out to stop folder markers from breaking the transfer, but I think it works better built around one rule, that an empty folder is never silently dropped, which is also where the S3 side landed. On SFTP that would mean the following.
With the rule in place, the logic this PR added to guard those corner cases should go away as well. For the switch, I wonder if |
|
Hello @yuseok89 - thank you for your contributions to Apache Airflow! The Airflow community has introduced a limit of 5 open pull requests at a time for contributors without write access to the repository. You currently have 11 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:
These pull requests stay open because maintainers are already engaged in them - they count towards your limit:
This is not a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are. What we ask you to do is to make your first prioritization decision: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack. Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst. Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting |
Yes, I agree, it's related and could suite for this case. Also I'm unsure if should be treated as a bug fix or breaking changes alredy (in terms of the semver and release notes), maybe release manager will help to identify in the future. P.S. |
GCSToSFTPOperatorcopies every nameGCSHook.list()returns, including the trailing-/folder markers a GCS listing contains. Here a marker does not just add a stray file. It fails the task._resolve_destination_pathnormalises the target withos.path.normpath, which strips the trailing slash, sofolder/targets the file path<dest>/folder. GCS lists lexicographically, so the marker is written first.folder/file.txtthen needs<dest>/folderto be a directory, andSFTPHook.create_directoryraises"... already exists and is a file".The fix drops a trailing-
/key only when it is also a strict prefix of another key in the same listing, meaning a directory whose children are right there. An object that merely happens to end in/has no such overlap and is left alone.Before / After
Listing:
folder/(a marker),folder/file.txt, andlonely/(a real object whose name ends in/).folder/<dest>/folderfolder/file.txt<dest>/folder/file.txtlonely/<dest>/lonelyWriting
folder/as a file is what breaksfolder/file.txt. The path its parent needs is already taken, and the task dies there.Verified end to end against a real GCS bucket and an SFTP server: the failure reproduces on
mainand the same run succeeds with this change.Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.