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 79d06691d6 fix(services/webdav): accept PROPFIND responses without 
getlastmodified (#9067)
79d06691d6 is described below

commit 79d06691d6f5cc2bd3584e90902a0e225fbcb4c4
Author: mola <[email protected]>
AuthorDate: Wed Nov 25 20:13:18 2026 +0800

    fix(services/webdav): accept PROPFIND responses without getlastmodified 
(#9067)
    
    parse_propstat failed with "propfind response missing getlastmodified"
    whenever a server omitted the property. RFC 4918 section 15.7 only
    requires getlastmodified on resources whose GET returns Last-Modified,
    so servers may leave it out, e.g. for collections or for backends
    without modification times. Against OpenDAL's own dav-server-opendalfs
    on the memory service, this made every write, stat, list and
    create_dir fail.
    
    Leave last_modified unset when the property is missing.
    
    Co-authored-by: Mola-maker <[email protected]>
---
 core/services/webdav/src/core.rs | 48 +++++++++++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/core/services/webdav/src/core.rs b/core/services/webdav/src/core.rs
index 32d2366585..b1b97fc628 100644
--- a/core/services/webdav/src/core.rs
+++ b/core/services/webdav/src/core.rs
@@ -1050,14 +1050,12 @@ pub fn parse_propstat(propstat: &Propstat) -> 
Result<Metadata> {
         m.etag(v);
     }
 
-    // https://www.rfc-editor.org/rfc/rfc4918#section-14.18
-    let Some(getlastmodified) = getlastmodified else {
-        return Err(Error::new(
-            ErrorKind::Unexpected,
-            "propfind response missing getlastmodified",
-        ));
-    };
-    m.last_modified(Timestamp::parse_rfc2822(getlastmodified)?);
+    // RFC 4918 section 15.7 only requires `getlastmodified` on resources whose
+    // GET returns `Last-Modified`, so servers may omit it, e.g. for
+    // collections or backends without modification times.
+    if let Some(getlastmodified) = getlastmodified {
+        m.last_modified(Timestamp::parse_rfc2822(getlastmodified)?);
+    }
 
     // the storage services have returned all the properties
     Ok(m.build())
@@ -1287,6 +1285,40 @@ mod tests {
         assert_eq!(meta.etag(), Some("\"example-etag\""));
     }
 
+    #[test]
+    fn test_parse_propstat_without_getlastmodified() {
+        let file = Propstat {
+            status: "HTTP/1.1 200 OK".to_string(),
+            prop: Prop {
+                getlastmodified: None,
+                getetag: None,
+                getcontentlength: Some("5".to_string()),
+                getcontenttype: None,
+                resourcetype: ResourceTypeContainer::default(),
+            },
+        };
+        let meta = parse_propstat(&file).unwrap();
+        assert!(meta.is_file());
+        assert_eq!(meta.content_length(), 5);
+        assert_eq!(meta.last_modified(), None);
+
+        let dir = Propstat {
+            status: "HTTP/1.1 200 OK".to_string(),
+            prop: Prop {
+                getlastmodified: None,
+                getetag: None,
+                getcontentlength: None,
+                getcontenttype: None,
+                resourcetype: ResourceTypeContainer {
+                    collection: Some(Collection {}),
+                },
+            },
+        };
+        let meta = parse_propstat(&dir).unwrap();
+        assert!(meta.is_dir());
+        assert_eq!(meta.last_modified(), None);
+    }
+
     #[test]
     fn test_parse_propstats_skips_failed_propstat() {
         let propstats = vec![

Reply via email to