You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/08/15 07:43:13 UTC

[PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

PDGGK opened a new pull request, #8081:
URL: https://github.com/apache/opendal/pull/8081

   ### Which issue does this PR close?
   
   None — found while reading the service.
   
   ### Rationale for this change
   
   `list_folder` is the only method in `pcloud/src/core.rs` that formats `path={}` rather than `path=/{}`, and the only one that runs the value through `normalize_root` first:
   
   ```rust
   let path = build_abs_path(&self.root, path);
   let path = normalize_root(&path);          // <- nothing else does this
   let path = path.trim_end_matches('/');
   let url = format!("{}/listfolder?path={}&...", ...);   // <- and no leading /
   ```
   
   Compare `stat`, twenty lines above, which is the shape the other ten call sites use:
   
   ```rust
   let path = build_abs_path(&self.root, path);
   let path = path.trim_end_matches('/');
   let url = format!("{}/stat?path=/{}&...", ...);
   ```
   
   The two differences cancel out for every input except one. `build_abs_path` returns `root[1..]` when the path is `"/"`, so with the default root that is the empty string; `normalize_root` turns it back into `"/"`, and `trim_end_matches('/')` removes it again — leaving the parameter empty:
   
   | root | call | `list_folder` sends | `stat` sends |
   |---|---|---|---|
   | `/` | `list("/")` | **`path=`** | `path=/` |
   | `/` | `list("a/")` | `path=/a` | `path=/a` |
   | `/data/` | `list("/")` | `path=/data` | `path=/data` |
   
   So listing the root of a default-rooted operator asks pCloud for an empty path. Either the API rejects it — surfaced as `ErrorKind::Unexpected` — or it answers `result: 2005`, which `lister.rs` treats as "done, no entries", i.e. an empty listing reported as success.
   
   ### What changes are included in this PR?
   
   The `normalize_root` hop goes, and the format string uses `path=/{}` like its neighbours. Two lines.
   
   **Blast radius**: every non-root input produces a byte-identical URL, as the table shows. Only the service-root case changes, and it changes to what `stat` already sends for the same operator.
   
   ### Tests
   
   None — the change makes one call site match the ten around it, and the reasoning is the two helpers' documented behaviour.
   
   `cargo build`, `cargo clippy -p opendal-service-pcloud --all-targets` (zero warnings) and `cargo fmt --all -- --check` are clean. There is no directory under `.github/services` for pcloud, so nothing was exercising this.
   
   ### Are there any user-facing changes?
   
   Yes: `list("")` / `list("/")` on a pcloud operator with the default root now asks for the root rather than for an empty path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #8081:
URL: https://github.com/apache/opendal/pull/8081#issuecomment-5303632145

   You're right, and I've taken the suggestion — `4aad5f0`.
   
   The unsoundness is that `normalize_root` is not only putting the leading `/` back. It also collapses empty segments:
   
   ```rust
   v.split('/').filter(|v| !v.is_empty()).collect::<Vec<&str>>().join("/")
   ```
   
   Dropping it took that with it, so a path with an interior `//` would have come out differently. My description claimed every non-root input was byte-identical; that was wrong. Running all three variants through the real helpers:
   
   | root | path | main today | as I filed it | with your suggestion |
   |---|---|---|---|---|
   | `/` | `"/"` | `path=` | `path=/` | `path=/` |
   | `/` | `""` | `path=` | `path=/` | `path=/` |
   | `/` | `"a/"` | `path=/a` | `path=/a` | `path=/a` |
   | `/` | `"a/b/"` | `path=/a/b` | `path=/a/b` | `path=/a/b` |
   | `/data/` | `"/"` | `path=/data` | `path=/data` | `path=/data` |
   | `/data/` | `"a/"` | `path=/data/a` | `path=/data/a` | `path=/data/a` |
   | `/` | `"a//b"` | `path=/a/b` | **`path=/a//b`** | `path=/a/b` |
   | `/` | `"a//b/"` | `path=/a/b` | **`path=/a//b`** | `path=/a/b` |
   | `/` | `"a b/"` | `path=/a%20b` | `path=/a%20b` | `path=/a%20b` |
   
   Two rows diverge, both of them mine.
   
   So the diff is now three lines on top of `main`, with `normalize_root` and the original format string untouched:
   
   ```rust
   let path = path.trim_end_matches('/');
   
   // Trimming leaves nothing when the target is the service root; every other
   // method here sends `/` for it rather than an empty parameter.
   let path = if path.is_empty() { "/" } else { path };
   ```
   
   Only the root case moves, from an empty parameter to `/`, which is what `stat` and the others already send for the same operator.
   
   `cargo clippy -p opendal-service-pcloud --all-features --all-targets -- -D warnings` and `cargo fmt` are clean.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #8081:
URL: https://github.com/apache/opendal/pull/8081#discussion_r3789910428


##########
core/services/pcloud/src/core.rs:
##########
@@ -425,12 +425,10 @@ impl PcloudCore {
     ) -> Result<Response<Buffer>> {
         let path = build_abs_path(&self.root, path);
 
-        let path = normalize_root(&path);
-
         let path = path.trim_end_matches('/');

Review Comment:
   Wouldn't handle special `/` here work?
   
   Your patch is not sound.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan merged PR #8081:
URL: https://github.com/apache/opendal/pull/8081


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #8081:
URL: https://github.com/apache/opendal/pull/8081#issuecomment-5305126378

   Removed. The diff is now the single line, clippy and fmt clean.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(services/pcloud): send the service root as / rather than empty [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #8081:
URL: https://github.com/apache/opendal/pull/8081#discussion_r3790669637


##########
core/services/pcloud/src/core.rs:
##########
@@ -429,6 +429,10 @@ impl PcloudCore {
 
         let path = path.trim_end_matches('/');
 
+        // Trimming leaves nothing when the target is the service root; every other

Review Comment:
   Remove the comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org