Xuanwo opened a new pull request, #8981:
URL: https://github.com/apache/opendal/pull/8981
# Which issue does this PR close?
Related Issues: None.
# Rationale for this change
An audit of `opendal-service-azdls` identified six protocol and logic bugs
that can cause silent data overwrites on conditional writes, loss of ADLS Gen2
JSON error messages and misclassified `401`/`412` errors, rejected `202
Accepted` recursive deletes, infinite pagination or directory parse failures
during listing, `stat` failures on directories without trailing `/` or
`Content-Length`, and invalid endpoint/header construction.
# What changes are included in this PR?
1. **Prevent silent overwrite on conditional `CreateFile` (`writer.rs`):**
Treat `if_none_match("*")` as `if_not_exists` when classifying `409
PathAlreadyExists` in `AzdlsWriter::create_if_needed`, and never swallow
`ErrorKind::AlreadyExists` when `op.is_conditional()` is true while preserving
unconditional overwrite and append behavior.
2. **Fix ADLS Gen2 DFS error parsing and classification (`core.rs`):** Parse
ADLS Gen2 JSON error bodies (`{"error":{"code":"...","message":"..."}}`) first
with XML fallback and `x-ms-error-code` header fallback without discarding body
messages; preserve `ErrorKind::ConditionNotMatch` for `412 PreconditionFailed`
caller-condition failures (including `SourceConditionNotMet`,
`TargetConditionNotMet`, and other non-lease precondition codes); map `401
Unauthorized` to `ErrorKind::PermissionDenied`.
3. **Accept `202 Accepted` on delete (`deleter.rs`):** Handle
`StatusCode::OK | StatusCode::ACCEPTED` in `AzdlsDeleter::delete_once` so `202
Accepted` responses returned by `azdls_recursive_delete` succeed instead of
failing with `Unexpected`.
4. **Fix listing continuation, directory `contentLength`, and ETag handling
(`lister.rs`):** Trim `x-ms-continuation` and mark listing complete when absent
or empty; parse `contentLength` only for `EntryMode::FILE`; set `etag` only
when non-empty and avoid double-quoting already-quoted or weak ETags.
5. **Inspect `x-ms-resource-type` before parsing `stat` metadata
(`core.rs`):** Check `x-ms-resource-type` first in
`AzdlsCore::azdls_stat_metadata` so `stat("dir")` without a trailing `/` or
`Content-Length` succeeds as `EntryMode::DIR` while files still require
`Content-Length`.
6. **Validate `endpoint` and deduplicate `If-None-Match` (`backend.rs`,
`core.rs`):** Reject empty, whitespace-only, or slash-only endpoints in
`AzdlsBuilder::build_backend` with `ErrorKind::ConfigInvalid`, and deduplicate
`If-None-Match` in `azdls_create` when both `if_not_exists` and `if_none_match`
are set.
7. **Add unit and mock `HttpTransport` tests:** Add coverage for all six
fixes and their edge cases across `backend.rs`, `core.rs`, `deleter.rs`,
`lister.rs`, and `writer.rs`.
# Are there any user-facing changes?
- `write_with(...).if_none_match("*")` now returns
`ErrorKind::ConditionNotMatch` on `409 PathAlreadyExists` instead of silently
overwriting existing files.
- `401 Unauthorized` responses now map to `ErrorKind::PermissionDenied`,
`412 PreconditionFailed` conditional errors stay
`ErrorKind::ConditionNotMatch`, and ADLS Gen2 JSON error messages are preserved.
- Recursive deletes returning `202 Accepted`, directory `stat` calls without
trailing `/` or `Content-Length`, and listings with empty continuation headers,
directory entries omitting `contentLength`, or empty/quoted ETags now succeed.
- Building an `Azdls` backend with an empty or slash-only endpoint now fails
immediately with `ErrorKind::ConfigInvalid`.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Implemented the six locally verifiable fixes in
`core/services/azdls` and wrote unit and mock `HttpTransport` regression tests.
Verification used local unit tests and mock HTTP responses rather than a live
Azure ADLS Gen2 account; live-cloud wire behavior outside these protocol/logic
fixes was left unchanged.
--
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]