Skip to content

fix(services/gcs): encode object paths exactly once - #7947

Merged
Xuanwo merged 5 commits into
mainfrom
xuanwo/fix-gcs-encoding-with-reqsign-rc
Jul 27, 2026
Merged

Xuanwo merged 5 commits into
mainfrom
xuanwo/fix-gcs-encoding-with-reqsign-rc

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #7942.

This restores the fix for #7926 after #7927 was reverted by #7943. It depends on apache/reqsign#785, released in reqsign v0.20.3.

Rationale for this change

GCS request builders own percent-encoding, but the writer currently pre-encodes logical object paths before passing them to those builders. Nested object names are therefore encoded twice and cannot be read back through the same OpenDAL path.

#7927 removed the writer-side encoding, but the reqsign implementation used at that time decoded and rebuilt caller-owned query URIs during signing. That caused real GCS behavior tests to fail and required the revert. Reqsign v0.20.3 treats the input URI as wire-ready and preserves it during header signing, so OpenDAL can encode the GCS path exactly once without the signer changing the request.

An A/B reproducer using the same GCS upload URI fails with the pre-0.20.3 package set (failed to apply signing request, URI replaced with /) and succeeds with the published v0.20.3 package set while preserving the complete URI.

What changes are included in this PR?

  • Align all reqsign dependencies with the published v0.20.3 package set and resolve them from crates.io without repository-level patches.
  • Pass logical GCS writer paths unchanged and percent-encode them once in request builders, including multipart initiation.
  • Add a signed-request regression test that asserts the wire URI is preserved and not double-encoded.
  • Extend the special-character behavior test with a nested path separator.

This PR remains draft while CI reruns against the published crates. The previous head passed both real GCS behavior configurations.

Are there any user-facing changes?

Yes. GCS writes to nested or reserved-character object names use the same logical object name as read, stat, and multipart operations. There is no public API or call-site change.

Verification

  • cargo metadata --locked --format-version 1 in the core and Ruby workspaces, plus independent resolution in the .NET and OCaml workspaces.
  • cargo check --workspace --all-targets --all-features --locked.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings.
  • Unit and doc tests for every reqsign-backed OpenDAL service.
  • ./scripts/workspace.py cargo fmt -- --check.
  • taplo format --check.
  • Real GCS behavior tests: gcs and gcs_with_default_storage_class.

AI Usage Statement

OpenAI Codex (GPT-5) was used to analyze the cross-repository signing contract, implement the change, and run validation. The resulting diff and test output were reviewed by the author.

@Xuanwo
Xuanwo marked this pull request as ready for review July 27, 2026 01:45
@Xuanwo
Xuanwo requested a review from PsiACE as a code owner July 27, 2026 01:45
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Jul 27, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 27, 2026
@Xuanwo
Xuanwo merged commit 7ce945d into main Jul 27, 2026
191 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/fix-gcs-encoding-with-reqsign-rc branch July 27, 2026 01:51
SeverinAlexB added a commit to pubky/pubky-homeserver that referenced this pull request Oct 16, 2026
opendal 0.58.1 fixes the GCS writer that percent-encoded object names
twice (apache/opendal#7947), the cause of the objects that v0.13.0 to
v0.16.1 misnamed. The repair of those objects stays: upstream does not
move them.

opendal 0.58 replaced the accessor and layer API, so the homeserver's
layers are ported to the new `Service` trait:

- Layers wrap a type-erased `Servicer`, and every call carries an
  `OperationContext`. The finalization and the staged publish reach the
  backend as an `Operator` built from both.
- Writers and copiers are now created synchronously. The write path
  check and the collision preflight run before the first byte, the
  close, or the copy reaches the backend, see `preflight`.

The generation condition on a publish or delete is now opendal's own
`if_version_match`, which GCS sends as `ifGenerationMatch`. The HTTP
client that added the condition behind opendal's back is removed:
opendal 0.59 reports a refusal of a condition it did not set as
`Unexpected`, not `ConditionNotMatch`, so stale publishes would no
longer read as conflicts. Checked against a real bucket.

GCS now refuses a conditional delete of a missing object. The name
repair treats such a refusal as done when the object is gone, as when
two homeservers repair at once.

`dav-server-opendalfs` moves to 0.7.10, the release built on opendal
0.59.4. Requires Rust 1.91.

Refs #703
SeverinAlexB added a commit to pubky/pubky-homeserver that referenced this pull request Oct 16, 2026
opendal 0.58.1 fixes the GCS writer that percent-encoded object names
twice (apache/opendal#7947), the cause of the objects that v0.13.0 to
v0.16.1 misnamed. The repair of those objects stays: upstream does not
move them.

opendal 0.58 replaced the accessor and layer API, so the homeserver's
layers are ported to the new `Service` trait:

- Layers wrap a type-erased `Servicer`, and every call carries an
  `OperationContext`. The finalization and the staged publish reach the
  backend as an `Operator` built from both.
- Writers and copiers are now created synchronously. The write path
  check and the collision preflight run before the first byte, the
  close, or the copy reaches the backend, see `preflight`.

The generation condition on a publish or delete is now opendal's own
`if_version_match`, which GCS sends as `ifGenerationMatch`. The HTTP
client that added the condition behind opendal's back is removed:
opendal 0.59 reports a refusal of a condition it did not set as
`Unexpected`, not `ConditionNotMatch`, so stale publishes would no
longer read as conflicts. Checked against a real bucket.

GCS now refuses a conditional delete of a missing object. The name
repair treats such a refusal as done when the object is gone, as when
two homeservers repair at once.

The name repair copies a misnamed object with a compose of one source
instead of a copy. opendal's GCS service takes a source generation on a
compose but not on a copy, and the repair must copy only the generation
whose content it checked: a replaced source is gone and answers 404,
which makes the repair look at the entry again. The object made is a
composite one, which keeps the content type passed but has no MD5.

`dav-server-opendalfs` moves to 0.7.10, the release built on opendal
0.59.4. Requires Rust 1.91.

Refs #703
SeverinAlexB added a commit to pubky/pubky-homeserver that referenced this pull request Oct 19, 2026
opendal 0.58.1 fixes the GCS writer that percent-encoded object names
twice (apache/opendal#7947), the cause of the objects that v0.13.0 to
v0.16.1 misnamed. The repair of those objects stays: upstream does not
move them.

opendal 0.58 replaced the accessor and layer API, so the homeserver's
layers are ported to the new `Service` trait:

- Layers wrap a type-erased `Servicer`, and every call carries an
  `OperationContext`. The finalization and the staged publish reach the
  backend as an `Operator` built from both.
- Writers and copiers are now created synchronously. The write path
  check and the collision preflight run before the first byte, the
  close, or the copy reaches the backend, see `preflight`.

The generation condition on a publish or delete is now opendal's own
`if_version_match`, which GCS sends as `ifGenerationMatch`. The HTTP
client that added the condition behind opendal's back is removed:
opendal 0.59 reports a refusal of a condition it did not set as
`Unexpected`, not `ConditionNotMatch`, so stale publishes would no
longer read as conflicts. Checked against a real bucket.

GCS now refuses a conditional delete of a missing object. The name
repair treats such a refusal as done when the object is gone, as when
two homeservers repair at once.

The name repair copies a misnamed object with a compose of one source
instead of a copy. opendal's GCS service takes a source generation on a
compose but not on a copy, and the repair must copy only the generation
whose content it checked: a replaced source is gone and answers 404,
which makes the repair look at the entry again. The object made is a
composite one, which keeps the content type passed but has no MD5.

`dav-server-opendalfs` moves to 0.7.10, the release built on opendal
0.59.4. Requires Rust 1.91.

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

Labels

lgtm This PR has been approved by a maintainer releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: gcs behavior test failure

2 participants