Repository navigation
fix(cache): attach s3://bucket/key context to body-phase stream errors - #1618
Conversation
S3 GET body-phase stream errors surfaced from `ReaderStream` after the `GetObject` future returned, so they lost the `s3://bucket/key` prefix that header-phase errors carry from `classify_get_object_error` (deferred out of #271). Thread `log_target` through a per-chunk `map` adapter that prepends the prefix on the error arm only. The wrapper is deliberately narrow so it does not disturb `retry::classify_io_error`: it passes typed markers (`BlobTooLargeMarker` / `OriginError`) through untouched so their downcast still fires, and preserves the original `io::ErrorKind` so transient/permanent routing of network faults is unchanged. Closes #1617 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Coverage reportTotal: 80.33% (was 80.30%, ▲ +0.02%) — 57158/71158 lines
History
|
There was a problem hiding this comment.
Pull request overview
This PR improves S3-origin observability in decdn-cache by ensuring body/stream-phase S3 GET failures retain the same s3://bucket/key context that header-phase errors already include, without changing retry classification behavior.
Changes:
- Added a
prefix_body_stream_error(log_target, io::Error)helper to attachs3://bucket/keycontext to mid-streamio::Errors while preservingio::ErrorKindand typed markers. - Wired the helper into the S3 fetch body stream via a per-item
StreamExt::map(...)adapter. - Added focused unit tests validating prefixing behavior and preserving
classify_io_errorrouting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR #1618 review: - `prefix_body_stream_error` now wraps the original `io::Error` in a private `PrefixedBodyError` struct whose `Display` prepends the `s3://bucket/key` prefix and whose `source()` returns the original error, instead of flattening it into a formatted `String`. The `io::ErrorKind` is still preserved and typed markers (`BlobTooLargeMarker` / `OriginError`) still pass through untouched. Added a test assertion that the original error is reachable via `std::error::Error::source`. - Reword the `map`-adapter comment: the per-chunk closure runs for every item; it is a cheap passthrough on `Ok` (no allocation) and only builds the prefixed error on `Err`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What
S3 GET failures during the body/stream phase lost the
s3://bucket/keyprefix that header-phase errors carry. The body error surfaces fromReaderStreamafter theGetObjectfuture has already returned, solog_targetcould not be attached with a single.context(...)call — it has to be threaded through a per-chunkmapadapter. This was deferred out of #271 and untracked since.Change
crates/cache/src/origin/s3.rs: newprefix_body_stream_error(log_target, io::Error)helper, wired onto the finalOriginByteStreaminfetchviastream.map(...). It fires only on the error arm; the happy path is untouched.retry::classify_io_error, which the engine runs over every body-phase error:BlobTooLargeMarker/OriginError, e.g.DecompressionFailed) pass through untouched so their downcast still fires and staysPermanent— re-wrapping them in aStringwould hide the marker and silently reclassify a deterministic permanent error as a transientOther;io::ErrorKindis preserved on the prefixed error, so transient/permanent routing of network faults (UnexpectedEof,ConnectionReset, …) is unchanged.Tests
Three unit tests over the helper (the meat of the change):
body_stream_error_gains_s3_prefix— plain network fault gains the prefix and keeps its kind.body_stream_error_preserves_retry_classification— a prefixedUnexpectedEofstill classifiesTransient.body_stream_error_passes_typed_marker_through— a typedOriginErrormarker passes through unwrapped and still classifiesPermanent.cargo nextest run -p decdn-cache: 327 passed, 0 failed.Closes #1617
🤖 Generated with Claude Code