You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Somsubhra-Nandi (via GitHub)" <gi...@apache.org> on 2025/12/31 06:53:10 UTC

[PR] fix(onedrive): correctly handle root directory listing [opendal]

Somsubhra-Nandi opened a new pull request, #7114:
URL: https://github.com/apache/opendal/pull/7114

   This PR fixes an issue where `list("/")` on the OneDrive service returns an empty result.
   
   Root cause:
   The OneDrive API treats the root directory differently from subpaths. The existing implementation formatted the root path like a normal directory, resulting in an invalid `root:/:/children` endpoint.
   
   Fix:
   Special-case the root path (`"/"`) to use `/me/drive/root/children` when building the list request URL.
   
   This aligns OpenDAL’s behavior with OneDrive API expectations.
   
   Fixes #7102
   


-- 
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(onedrive): correctly handle root directory listing [opendal]

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


##########
core/services/onedrive/src/lister.rs:
##########
@@ -29,6 +29,32 @@ use super::graph_model::GENERAL_SELECT_PARAM;
 use super::graph_model::GraphApiOneDriveListResponse;
 use super::graph_model::ItemType;
 
+// --- Helper Function for URL Generation (Logic Extracted Here) ---
+// We use a closure `item_url_fn` to mock the behavior of `onedrive_item_url`
+// so we can test this without a real OneDriveCore instance.
+fn build_request_url(

Review Comment:
   Please don't extract helper functions in this way. If we do want to assert if the generated URL correctly. 
   
   We can split APIs in to `xxx_request() -> http::Request` and `xxx()` which will call `xxx_request()` inside.
   
   In this way, we just need to call `xxx_request()` and check the generated requests.



##########
core/services/onedrive/src/lister.rs:
##########
@@ -130,10 +140,6 @@ impl oio::PageList for OneDriveLister {
             let last_modified = drive_item.last_modified_date_time.parse::<Timestamp>()?;
             meta.set_last_modified(last_modified);
 
-            // When listing a directory with `$expand=versions`, OneDrive returns 400 "Operation not supported".

Review Comment:
   The same.



##########
core/services/onedrive/src/lister.rs:
##########
@@ -83,18 +99,13 @@ impl oio::PageList for OneDriveLister {
 
         // Include the current directory itself when handling the first page of the listing.
         if ctx.token.is_empty() && !ctx.done {
-            // TODO: when listing a directory directly, we could reuse the stat result,

Review Comment:
   Please don't touch unrelated code.



##########
core/tests/behavior/async_list.rs:
##########
@@ -34,6 +34,7 @@ pub fn tests(op: &Operator, tests: &mut Vec<Trial>) {
             op,
             test_check,
             test_list_dir,
+            test_list_root_dir,

Review Comment:
   We do not need this test, and it does not work in practice because all our behavior tests set a random root directory during tests.



-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   @meteorgan Thanks for the suggestion!
   
   Yes, that makes sense — I can add a regression test to cover listing the OneDrive root directory. I’ll work on adding a test to ensure `list("/")` returns entries correctly and update the PR accordingly.
   


-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   @meteorgan 
   Updates:
   Refactor: I've extracted the URL generation logic into a helper function build_request_url as requested.
   
   Tests: Added unit tests to cover both root (/) and non-root paths, ensuring the URL structure is correct.
   
   Style: Ran cargo fmt to ensure compliance with the project's code style.
   
   Note on CI: I noticed the C Bindings and OCaml checks failed due to network timeouts (HTTP 504 / SSL handshake errors) while downloading dependencies. These seem unrelated to my changes in onedrive.
   
   Ready for review!
   
   > Thanks for your contribution. Could we add a test for this behavior ?
   
   


-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   could we have a test for this behavior ?


-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   > Hi, @Somsubhra-Nandi What I meant was that it would be better to add a test case to expose the current bug and demonstrate that this PR fixes it. So we may need to add a corresponding test case in `tests/behavior/async_list.rs`.
   
   Thanks for the clarification — that makes sense now.
   
   I’ll add a behavior-level regression test in tests/behavior/async_list.rs that exercises list("/") on the OneDrive service, so the bug is exposed on main and verified as fixed by this PR.
   
   I’ll update the PR shortly.


-- 
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(onedrive): correctly handle root directory listing [opendal]

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


##########
core/services/onedrive/src/lister.rs:
##########
@@ -29,6 +29,32 @@ use super::graph_model::GENERAL_SELECT_PARAM;
 use super::graph_model::GraphApiOneDriveListResponse;
 use super::graph_model::ItemType;
 
+// --- Helper Function for URL Generation (Logic Extracted Here) ---
+// We use a closure `item_url_fn` to mock the behavior of `onedrive_item_url`
+// so we can test this without a real OneDriveCore instance.
+fn build_request_url(
+    token: &str,
+    path: &str,
+    limit: Option<usize>,
+    item_url_fn: impl Fn(&str) -> String,
+) -> String {
+    if !token.is_empty() {
+        return token.to_string();
+    }
+
+    let base = if path == "/" {
+        format!("/me/drive/root/children?{}", GENERAL_SELECT_PARAM)

Review Comment:
   this expression is  missing `API Root`. If path is  "/"  this will only return relative path and not fully qualified url. 



-- 
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(onedrive): correctly handle root directory listing [opendal]

Posted by "Somsubhra-Nandi (via GitHub)" <gi...@apache.org>.
Somsubhra-Nandi closed pull request #7114: fix(onedrive): correctly handle root directory listing
URL: https://github.com/apache/opendal/pull/7114


-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   Hi, @Somsubhra-Nandi What I meant was that it would be better to add a test case to expose the current bug and demonstrate that this PR fixes it. So we may need to add a corresponding test case in `tests/behavior/async_list.rs`.


-- 
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(onedrive): correctly handle root directory listing [opendal]

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

   > Hi, @Somsubhra-Nandi What I meant was that it would be better to add a test case to expose the current bug and demonstrate that this PR fixes it. So we may need to add a corresponding test case in `tests/behavior/async_list.rs`.
   
   I have added a test case in `tests/behavior/async_list.rs`.


-- 
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