Skip to content

fix(services/gcs): reject multipart writes with if_not_exists - #8046

Open
dgvj-work wants to merge 1 commit into
apache:mainfrom
dgvj-work:fix/gcs-multipart-if-not-exists
Open

fix(services/gcs): reject multipart writes with if_not_exists#8046
dgvj-work wants to merge 1 commit into
apache:mainfrom
dgvj-work:fix/gcs-multipart-if-not-exists

Conversation

@dgvj-work

@dgvj-work dgvj-work commented Aug 11, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Closes #8040

Rationale for this change

GCS supports write_with_if_not_exists for single-shot uploads via ifGenerationMatch=0, but the multipart writer uses the XML API, which cannot carry request preconditions. After #8028/#8041 added chunked-writer coverage, that path could silently overwrite an existing object when if_not_exists(true) was set.

Moving multipart onto resumable uploads (issue option 2) is a larger change. This PR takes the fail-closed approach: refuse the unsupported combination instead of advertising success and overwriting.

What changes are included in this PR?

  • Return Unsupported from GcsWriter::initiate_part when if_not_exists is set.
  • Keep single-shot write_once conditional creates working via the JSON upload API.
  • Update test_writer_write_with_if_not_exists so GCS asserts Unsupported instead of skipping.

Are there any user-facing changes?

Yes. writer_with(...).if_not_exists(true) on GCS now returns Unsupported when the multipart path would be used, instead of overwriting. write_with(...).if_not_exists(true) is unchanged.

AI Usage Statement

None.

GCS XML multipart uploads cannot enforce request preconditions, so
fail closed with Unsupported instead of silently overwriting. Single-shot
conditional writes continue to use ifGenerationMatch=0 on the JSON API.
@dgvj-work
dgvj-work requested a review from Xuanwo as a code owner August 11, 2026 01:07
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Aug 11, 2026
@erickguan

Copy link
Copy Markdown
Member

Returning Unsupported is quite an abrupt exception. I would want to see investigation on if OpenDAL could support multipart upload.

If this is truly impossible, it's probably better to consider the nuance for "write_with_if_not_exists". e.g., either having some partial support flag or declaring false while sacrificing one-shot implementation.

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

Labels

releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

services/gcs: XML multipart writer cannot honor write_with_if_not_exists

2 participants