Skip to content

Fix GCSToGCSOperator ignoring replace=False for single-file copy#66014

Merged
shahar1 merged 1 commit intoapache:mainfrom
9re-pe:fix/gcs-to-gcs-replace-single-file
May 5, 2026
Merged

Fix GCSToGCSOperator ignoring replace=False for single-file copy#66014
shahar1 merged 1 commit intoapache:mainfrom
9re-pe:fix/gcs-to-gcs-replace-single-file

Conversation

@9re-pe
Copy link
Copy Markdown
Contributor

@9re-pe 9re-pe commented Apr 28, 2026

Summary

Respect replace=False in the single-file fallback path of
GCSToGCSOperator._copy_source_without_wildcard. When the source is a
single object (no wildcard), _ignore_existing_files correctly empties
objects if the destination already has the file, but the subsequent
if len(objects) == 0 and prefix: branch then called
_copy_single_object unconditionally, overwriting the destination.

This adds a destination existence check guarded by not self.replace
inside that branch, skipping the copy when the destination already exists.

Alternative considered

I also considered limiting the fallback itself to the case where the
source list was empty before _ignore_existing_files ran. The chosen
approach is smaller and keeps the intent local to where the copy happens;
happy to switch to the alternative if reviewers prefer it.

closes: #66009


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

When source_object is a single object (no wildcard) and the destination
already exists, _copy_source_without_wildcard fell into a fallback branch
that called _copy_single_object unconditionally, ignoring replace=False.

Closes apache#66009
@9re-pe 9re-pe requested a review from shahar1 as a code owner April 28, 2026 12:22
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Apr 28, 2026
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented Apr 28, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@eladkal
Copy link
Copy Markdown
Contributor

eladkal commented May 4, 2026

cc @VladaZakharova for review

Copy link
Copy Markdown
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@shahar1 shahar1 merged commit 565515c into apache:main May 5, 2026
93 checks passed
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 5, 2026

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GCSToGCSOperator ignores replace=False when copying a single file whose destination already exists

3 participants