Skip to content

cache: S3 origin does not support Content-Encoding decompression (HTTP origin does) #804

Description

@thiras

The S3 origin adapter rejects any non-identity Content-Encoding outright, while the HTTP origin adapter supports decompression via DecompressMode. This is an asymmetry that forces operators using S3/R2/B2 backends to pre-store canonical (uncompressed) bytes or front their bucket with an HTTP CDN that strips encoding.

Evidence

  • crates/cache/src/origin/s3.rs:483-499 — on any non-identity Content-Encoding, returns OriginPullError::Permanent with a pointer error. The comment notes decompression "is a follow-up issue (HttpOrigin::decompress_body is reusable)".
  • crates/cache/src/origin/http.rs:53-139 — HTTP origin already implements DecompressMode::{Auto,Strict} with an UnsupportedEncoding path.

Why it matters

The reason for rejecting is correct (BLAKE3 verify runs over canonical bytes, so a gzipped body would later trip a confusing hash mismatch). But the result is a real functional gap between the two first-class origin backends, and the comment indicates the fix is straightforward because the HTTP decode path is reusable.

Suggested fix

Reuse the HTTP origin decompression logic (DecompressMode) on the S3 backend so encoded objects decode to canonical bytes before the engine hash-verifies, with the same strict/auto semantics.

Filed during a repository review; verified not already tracked.

Activity

  1. added
    kind:feature
    rust
    prio:low
    on Jun 3, 2026
  2. github-actions commented on Jun 3, 2026

    @github-actions

    🎯 Triage report

    The S3/R2/B2 origin adapter currently hard-fails (OriginPullError::Permanent) on any non-identity Content-Encoding header, while the HTTP origin adapter already handles gzip/br/zstd via DecompressMode::{Auto,Strict}. The issue is well-evidenced with exact file locations, correctly identifies the root cause (BLAKE3 verification must run over decoded bytes), and points to a ready-made solution (HttpOrigin::decompress_body is already factored for reuse). Labels and priority already look accurate.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature Adds new capability to an existing adapter; not a regression
    Labels unchanged (enhancement, technical, rust, low) All four are accurate; low is appropriate — operators can work around it by pre-storing uncompressed objects
    Coding agent Suitable Scope is self-contained: extend S3Origin to call HttpOrigin::decompress_body (or extract it to a shared helper), mirror DecompressMode config field in S3OriginConfig, add a unit test with a mock encoded response

    🔗 Similar issues

    No duplicate or closely related open issues found.

    💡 Notes and suggestions

    Key files:

    • crates/cache/src/origin/s3.rs:483-499 — current rejection site; this is where decompression should be inserted before returning the body to the engine
    • crates/cache/src/origin/http.rs:53-139 — decompress_body implementation and DecompressMode usage to replicate or factor out

    Suggested sub-tasks:

    • Extract decompress_body (or a wrapper) to a shared location — either crates/cache/src/origin/mod.rs or a new crates/cache/src/origin/decompress.rs — so both adapters import it without a circular dependency
    • Add decompress: DecompressMode field to S3OriginConfig (mirror HttpOriginConfig); default to Auto to match the HTTP adapter's existing default
    • Call decompression after the GetObject response body is read but before returning bytes to the hash-verify layer
    • Add a unit test: mock S3 response with Content-Encoding: gzip, confirm canonical bytes are returned and hash check passes; also confirm Strict mode errors on unsupported encodings
    • Update config-types crate docs / config schema docs if DecompressMode is referenced there

    Config-types note: DecompressMode lives in crates/config-types/ which is a leaf crate (serde + url only). Any new config field on S3OriginConfig must stay within those constraints.

    Anti-panic policy reminder: the decompression path must propagate errors as Result — no .unwrap() / .expect() / indexing without bounds check (Clippy denies these workspace-wide).

    Generated by Agentic Triage for issue #804 · sonnet46 469.7K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:featureprio:lowrust

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions