Xuanwo opened a new pull request, #9010:
URL: https://github.com/apache/opendal/pull/9010
# Which issue does this PR close?
Related Issues: None.
# Rationale for this change
`opendal-service-obs` had four protocol and contract bugs that can cause
lost retryability, dropped error/metadata details, broken list pagination or
root scoping, and fabricated directory existence:
1. `ObsWriter::complete_part` deserialized the response body via
`resp.body_mut().reader()` before checking `resp.status()`. On non-XML `5xx`
gateway errors (such as HTML `502`/`503`), XML deserialization failed first
with a non-retryable `Unexpected` error instead of reaching `parse_error`. On
XML error responses (`403`/`404`/`409`/`500`), draining the body left
`parse_error` with an empty buffer and dropped OBS `<Code>`, `<Message>`, and
`<RequestId>`. On `200 OK` responses containing an `<Error>` XML body or an
empty `<ETag>`, `#[serde(default)]` caused `complete_part` to succeed with
`etag("")`.
2. `ObsCore::obs_list_objects` checked `if !path.is_empty()` instead of `if
!p.is_empty()` after resolving `p = build_absolute_path(&self.root, path)`,
emitting `?prefix=` when listing `/` under root `/` and omitting `prefix`
altogether when `Service::list` was called with `path == ""` under a non-root
`root` (escaping `root`). In addition, `ListObjectsOutput` omitted
`<IsTruncated>`, so `ObsLister::next_page` did not terminate when
`<IsTruncated>false</IsTruncated>` was returned alongside a non-empty
`<NextMarker>`.
3. `parse_error` did not map HTTP `416 Range Not Satisfiable` to
`ErrorKind::RangeNotSatisfied` or HTTP `401 Unauthorized` to
`ErrorKind::PermissionDenied`, and `ObsReader::open` only called
`parse_into_metadata`, dropping `x-obs-meta-*` user metadata and
`x-obs-version-id` headers that `ObsBackend::stat` parses.
4. `ObsBackend::stat` returned
`Ok(RpStat::new(MetadataBuilder::dir().build()))` on HTTP `404 Not Found` for
any trailing-slash path, fabricating existing directories when `SimulateLayer`
is disabled or `Service::stat` is called directly and masking `404` responses.
# What changes are included in this PR?
- Check `resp.status() != StatusCode::OK` before reading the response body
in `ObsWriter::complete_part`, add `code` and `message` fields to
`CompleteMultipartUploadResult`, and reject `200 OK` responses when
`!result.code.is_empty() || result.etag.is_empty()` by forwarding the intact
response to `parse_error`. Also preserve raw response text in `parse_error`
when XML deserializes to an empty `ObsError` (for example XHTML gateway error
pages or `<CompleteMultipartUploadResult/>`).
- Check `if !p.is_empty()` in `ObsCore::obs_list_objects`, deserialize
`is_truncated: Option<bool>` in `ListObjectsOutput`, and mark
`ObsLister::next_page` done when `is_truncated == Some(false)` or `next_marker`
is absent/empty.
- Map `StatusCode::RANGE_NOT_SATISFIABLE` to `ErrorKind::RangeNotSatisfied`
and `StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN` to
`ErrorKind::PermissionDenied` in `parse_error`.
- Extract shared `ObsCore::parse_metadata` (parsing `x-obs-meta-*` via
`parse_prefixed_headers` and `x-obs-version-id`) and use it in both
`ObsBackend::stat` and `ObsReader::open`.
- Remove the `StatusCode::NOT_FOUND if path.ends_with('/')` fabrication
branch from `ObsBackend::stat` so `404` flows into `parse_error` while
`SimulateLayer` continues to handle virtual directories.
- Add unit and mock `HttpTransport` tests in
`core/services/obs/src/{core,writer,lister,reader,backend}.rs` covering all
four fixes and edge cases.
# Are there any user-facing changes?
`ObsBackend::stat` now returns `ErrorKind::NotFound` on HTTP `404` for
missing trailing-slash paths when called directly without `SimulateLayer`;
`ObsReader::open` now populates `x-obs-meta-*` user metadata and
`x-obs-version-id`; HTTP `416` and `401` errors map to
`ErrorKind::RangeNotSatisfied` and `ErrorKind::PermissionDenied`; multipart
completion properly surfaces HTTP and `200 OK` XML errors with retryability
preserved; list pagination respects `<IsTruncated>` and resolved root prefixes.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: high
- Role: Investigated and verified the four `opendal-service-obs` bugs
against `origin/main`, implemented the fixes and mock `HttpTransport` unit
tests, and ran local unit, compile, clippy, format, and typo checks. Live
Huawei Cloud OBS integration tests were not executed in this environment; all
changes are scoped to pure protocol and Rust service logic verified via unit
and mock transport 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]