Skip to content

Skip GCS folder-marker keys in GCSToS3Operator - #72497

Merged
potiuk merged 1 commit into
apache:mainfrom
yuseok89:skip-gcs-folder-markers-in-gcs-to-s3
Sep 8, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
yuseok89:skip-gcs-folder-markers-in-gcs-to-s3

Conversation

@yuseok89

@yuseok89 yuseok89 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

GCSToS3Operator copies every name GCSHook.list() returns, including the trailing-/ folder markers a GCS listing contains. They land in S3 as spurious empty keys and in the XCom output. With flatten_structure=True a marker has no basename, so it resolves to the destination prefix itself and a zero-byte object is written over it.

This applies the same overlap-aware rule S3ToGCSOperator uses (#65724): a trailing-/ key is dropped only when it is also a strict prefix of another key in the same listing, so a real object like lonely/ is kept. Flattening needs one addition — a kept lonely/ still flattens to an empty name, so keys with no basename are dropped as well. Skipped keys are logged, and the returned list is now sorted and de-duplicated.

related: #64966, #65724

Before / After

Verified end to end against a real GCS bucket and a real S3 bucket. Listing: src/ (a marker), src/file.txt, and lonely/ (a real object ending in /).

S3 keys XCom
Before src/, src/file.txt, lonely/ all three
After src/file.txt, lonely/ those two

With flatten_structure=True into s3://bucket/dest/:

S3 keys XCom
Before dest/, dest/file.txt all three
After dest/file.txt src/file.txt

dest/ is a zero-byte object on the destination prefix, because both markers flatten to an empty basename. lonely/ is dropped only under flattening, where it has no name left.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    • Opus 5

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@boring-cyborg boring-cyborg Bot added area:providers provider:amazon AWS/Amazon - related issues labels Sep 4, 2026
@yuseok89
yuseok89 force-pushed the skip-gcs-folder-markers-in-gcs-to-s3 branch from 049b960 to 2b7622b Compare September 4, 2026 16:23
@yuseok89
yuseok89 force-pushed the skip-gcs-folder-markers-in-gcs-to-s3 branch from 2b7622b to adc6bc1 Compare September 4, 2026 16:33
@yuseok89 yuseok89 changed the title [WIP] Skip GCS folder-marker keys in GCSToS3Operator Skip GCS folder-marker keys in GCSToS3Operator Sep 4, 2026
@yuseok89
yuseok89 marked this pull request as ready for review September 4, 2026 18:42
@yuseok89
yuseok89 requested a review from o-nikolas as a code owner September 4, 2026 18:42
@potiuk
potiuk merged commit e56fcdf into apache:main Sep 8, 2026
160 checks passed
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
o-nikolas pushed a commit that referenced this pull request Sep 24, 2026
…72892)

Azure container listings include trailing-slash folder markers, which the
operator copied verbatim, leaving spurious empty keys in the destination
bucket and in the XCom output that downstream tasks consume. GCSToS3Operator
already applied an overlap-aware rule for this (#72497), so the two transfers
disagreed on identical input; both now share it. Sorting the replace=False
path makes the returned key order independent of which keys already exist in
S3.
regarmukesh3g pushed a commit to regarmukesh3g/airflow that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants