QazCetelic opened a new issue, #8940: URL: https://github.com/apache/opendal/issues/8940
### OpenDAL version or commit main (`516644ec3`) ### Affected service or component services/webdav ### Describe the bug It always uses the `If-Match` and `If-None-Match` strict match headers, but those will fail with weak ETags, which are used by Apache's own WebDAV implementation. https://github.com/apache/opendal/blob/780690864049d0c8c9c886817b26709c9bae979f/core/services/webdav/src/core.rs#L269-L273 `if_none_match` lets a PUT overwrite the file when it shouldn't, while `if_match` rejects a DELETE that should succeed. Reproduced against Apache using OpenDAL 0.59.5 at `688fdf606`. ### Steps to Reproduce 1. Write a file through the WebDAV operator, then immediately `stat` it and confirm that the returned ETag starts with `W/`. 2. Pass that ETag to `write_with(path, new_contents).if_none_match(etag)`. 3. Seed and stat a fresh file separately, then pass its current weak ETag to `delete_with(path).if_match(etag)`. Run this independently so a failed PUT assertion does not skip the DELETE check. ### Actual Behavior | Operation | Actual | Expected | | --- | --- | --- | | PUT with `if_none_match(current_weak_etag)` | Succeeds and overwrites the file | `ConditionNotMatch`; contents remain unchanged | | DELETE with `if_match(current_weak_etag)` | Returns `ConditionNotMatch`; file remains | Succeeds when the supplied ETag still equals the file’s current ETag | ### Expected Behavior I implemented it myself in a different way at https://github.com/QazCetelic/opendal/tree/feat/webdav-conditional-write (see `apply_etag_preconditions`), but due to personal reasons I hadn't had the chance to finish testing it to make a PR yet. All capabilities seem to work with it for lighttpd 1.4.85, Apache 2.4.71, SabreDAV 4.7.1. Only Nginx fails but I suspect that is unavoidable. ### Additional Context - **PUT — [`core.rs:267–268`](https://github.com/apache/opendal/blob/688fdf60671ef6480194656ca756700dcc1cd544/core/services/webdav/src/core.rs#L267-L268):** The `if_none_match` path sends only the HTTP `If-None-Match` header. Apache accepted the PUT despite the supplied weak ETag matching the current one. The existing WebDAV `If` fallback at [`core.rs:249–262`](https://github.com/apache/opendal/blob/688fdf60671ef6480194656ca756700dcc1cd544/core/services/webdav/src/core.rs#L249-L262) applies only to PUT’s `if_match` path. - **DELETE — [`core.rs:335–337`](https://github.com/apache/opendal/blob/688fdf60671ef6480194656ca756700dcc1cd544/core/services/webdav/src/core.rs#L335-L337):** DELETE sends the weak ETag as plain HTTP `If-Match`. That header uses strong comparison, so a weak validator cannot match even when it is the exact value OpenDAL just returned. DELETE has no WebDAV `If` fallback. This is currently not caught because the test (and several others) are disabled for all fixtures (`delete_with_if_match=false`) ### Reproduction confirmation - [x] I reproduced this issue against the affected component. For a service-specific report, I used the actual service rather than only a mock, emulator, or source-code analysis. ### Are you willing to submit a PR to fix this bug? - [ ] Yes, I would like to submit a PR. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
