You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/03/07 12:51:20 UTC

(opendal) branch main updated: fix(services/dropbox): fix dropbox batch test panic in ci (#4329)

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 53aa0b16ab fix(services/dropbox): fix dropbox batch test panic in ci (#4329)
53aa0b16ab is described below

commit 53aa0b16ab8771470d44ef1b140779ab4554dbe4
Author: zjregee <89...@users.noreply.github.com>
AuthorDate: Thu Mar 7 20:51:14 2024 +0800

    fix(services/dropbox): fix dropbox batch test panic in ci (#4329)
    
    * add error deserialization structure for batch
    
    * ignore path_lookup not_found error
    
    * improve comment
---
 core/src/services/dropbox/core.rs | 47 ++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/core/src/services/dropbox/core.rs b/core/src/services/dropbox/core.rs
index 3fff5115de..67c7cf5e57 100644
--- a/core/src/services/dropbox/core.rs
+++ b/core/src/services/dropbox/core.rs
@@ -15,6 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use std::collections::HashMap;
 use std::default::Default;
 use std::fmt::Debug;
 use std::fmt::Formatter;
@@ -37,7 +38,6 @@ use serde::Serialize;
 use tokio::sync::Mutex;
 
 use super::error::parse_error;
-use super::error::DropboxErrorResponse;
 use crate::raw::*;
 use crate::*;
 
@@ -337,12 +337,22 @@ impl DropboxCore {
                     (path, Ok(RpDelete::default().into()))
                 }
                 "failure" => {
-                    let error = entry.error.expect("error should be present");
-                    let err = Error::new(
-                        ErrorKind::Unexpected,
-                        &format!("delete failed with error {}", error.error_summary),
-                    );
-                    ("".to_string(), Err(err))
+                    let error = entry.failure.expect("error should be present");
+                    let error_cause = &error
+                        .failure_cause_map
+                        .get(&error.tag)
+                        .expect("error should be present")
+                        .tag;
+                    // Ignore errors about path lookup not found and report others.
+                    if error.tag == "path_lookup" && error_cause == "not_found" {
+                        ("".to_string(), Ok(RpDelete::default().into()))
+                    } else {
+                        let err = Error::new(
+                            ErrorKind::Unexpected,
+                            &format!("delete failed with error {} {}", error.tag, error_cause),
+                        );
+                        ("".to_string(), Err(err))
+                    }
                 }
                 _ => (
                     "".to_string(),
@@ -515,5 +525,26 @@ pub struct DropboxDeleteBatchResponseEntry {
     #[serde(rename(deserialize = ".tag"))]
     pub tag: String,
     pub metadata: Option<DropboxMetadataResponse>,
-    pub error: Option<DropboxErrorResponse>,
+    pub failure: Option<DropboxDeleteBatchFailureResponse>,
+}
+
+#[derive(Default, Debug, Deserialize)]
+#[serde(default)]
+pub struct DropboxDeleteBatchFailureResponse {
+    #[serde(rename(deserialize = ".tag"))]
+    pub tag: String,
+    // During the batch deletion process, Dropbox returns
+    // part of the error information in the form of a JSON key.
+    // Since it is impossible to determine the JSON key in advance,
+    // the error information is parsed into a HashMap here.
+    // The key of the HashMap is equal to the value of the tag above.
+    #[serde(flatten)]
+    pub failure_cause_map: HashMap<String, DropboxDeleteBatchFailureResponseCause>,
+}
+
+#[derive(Default, Debug, Deserialize)]
+#[serde(default)]
+pub struct DropboxDeleteBatchFailureResponseCause {
+    #[serde(rename(deserialize = ".tag"))]
+    pub tag: String,
 }