Skip to content

GCP: fix copy (no) overwrite semantics#713

Merged
tustvold merged 1 commit into
apache:mainfrom
james-rms:jrms/fix-gcp-copy-no-overwrite
May 20, 2026
Merged

GCP: fix copy (no) overwrite semantics#713
tustvold merged 1 commit into
apache:mainfrom
james-rms:jrms/fix-gcp-copy-no-overwrite

Conversation

@james-rms

@james-rms james-rms commented May 7, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #712

Rationale for this change

On main, GoogleCloudStorage::copy(src, dst) fails with Error::AlreadyExists if dst is the path to an existing object. This is the wrong default behavior - CopyMode defaults to Overwrite, not Create. This happens because of a bug in GoogleCloudStorage::copy_opts, where CopyMode::Overwrite gets mapped to if_not_exists = true instead of false.

What changes are included in this PR?

This PR fixes and moves the boolean mapping closest to where it gets used, to minimise confusion.

Are there any user-facing changes?

Yes. Anyone using GoogleCloudStorage::copy today who is relying on the incorrect behavior will see objects getting overwritten instead of an error.

@james-rms

Copy link
Copy Markdown
Contributor Author

Note: I believe the GCS emulator used in tests does not support object versioning, so I didn't try to add a test here. Up to reviewers judgement though.

@james-rms
james-rms force-pushed the jrms/fix-gcp-copy-no-overwrite branch from 831f3cf to ef6deac Compare May 7, 2026 11:50
@james-rms

Copy link
Copy Markdown
Contributor Author

@tustvold @crepererum sorry to bother - this feels reasonably high-impact to me as well as very simple to review. Are either of you available to take a look?

@tustvold tustvold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense to me, thank you

@tustvold
tustvold merged commit 994d607 into apache:main May 20, 2026
9 checks passed
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.

GoogleCloudStorage::copy overwrite semantics are flipped.

2 participants