Checksum mismatch for registries served with `Content-Encoding: gzip` (e.g. GitHub Pages)
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- rust
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi trong repository độc lập được liên kết bằng cargo run và bazel run :main, sau đó so sánh các checksum khi có và không có Accept-Encoding: gzip. Theo dõi đường dẫn tải xuống crate rules_rust và xác định liệu bản sửa lỗi thuộc về downloader hay các request header; công việc được coi là hoàn tất khi registry crate được tải xuống với checksum từ Cargo.lock và bản tái hiện build thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
We use a custom registry at Proton and found that we get a checksum mismatch when crate_universe fetches .crate files from it. The registry is hosted on GitHub Pages, which applies Content-Encoding: gzip based on the client's Accept-Encoding header.
I was able to reproduce this in a self-contained repository, please see https://github.com/mgeisler/gh-pages-registry-demo.
Environment
| Bazel | 9.1.0 |
| rules_rust | 0.70.0 |
| OS | macOS 26 (arm64) |
Repository structure
| Path | Purpose |
|---|---|
greet/ |
Library crate published to the registry |
hello/ |
Binary crate that depends on greet via the registry |
The registry is live at https://mgeisler.github.io/gh-pages-registry-demo/.
Reproducing the bug
Building with Cargo works:
cd hello && cargo run
Building with Bazel fails (Cargo.lock is already committed, no repinning needed):
cd hello && bazel run :main
Bazel output:
WARNING: Download from https://mgeisler.github.io/gh-pages-registry-demo/crates/greet-0.1.0.crate failed:
class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException
Checksum was dd22f693a0dc4bcd8d59c30b12ffe47ee355586964f211ba0878892ba46dfd3a
but wanted 93afd84f9dc5cd2b9dacc42f1dec536595ed068214a844c4e0a8a7032a7397f0
ERROR: An error occurred during the fetch of repository 'rules_rust++crate+crates__greet-0.1.0':
Error in download_and_extract: java.io.IOException: Error downloading
[https://mgeisler.github.io/gh-pages-registry-demo/crates/greet-0.1.0.crate]:
Checksum was dd22f693a0dc4bcd8d59c30b12ffe47ee355586964f211ba0878892ba46dfd3a
but wanted 93afd84f9dc5cd2b9dacc42f1dec536595ed068214a844c4e0a8a7032a7397f0
ERROR: Build did NOT complete successfully
Verifying the root cause with Curl
Without Accept-Encoding — what Cargo does; digest matches Cargo.lock:
curl -L "https://mgeisler.github.io/gh-pages-registry-demo/crates/greet-0.1.0.crate" \
| sha256sum
# → 93afd84f9dc5cd2b9dacc42f1dec536595ed068214a844c4e0a8a7032a7397f0 ✓
With Accept-Encoding: gzip — what Bazel's HTTP client sends:
curl -L -H "Accept-Encoding: gzip" \
"https://mgeisler.github.io/gh-pages-registry-demo/crates/greet-0.1.0.crate" \
| sha256sum
# → dd22f693a0dc4bcd8d59c30b12ffe47ee355586964f211ba0878892ba46dfd3a ✗
The response headers confirm that Fastly re-compresses the already-gzipped .crate:
content-type: application/octet-stream
content-encoding: gzip
vary: Accept-Encoding
We can verify this by hand:
curl -L -H "Accept-Encoding: gzip" \
"https://mgeisler.github.io/gh-pages-registry-demo/crates/greet-0.1.0.crate" \
| gunzip | sha256sum
# → 93afd84f9dc5cd2b9dacc42f1dec536595ed068214a844c4e0a8a7032a7397f0 ✓
Bazel hashes the gzip-encoded wire bytes: the .crate (already a .tar.gz) is gzipped a second time by Fastly, and Bazel checksums that doubly-compressed payload without decompressing it first.
Root cause
Bazel's downloader does not strip Content-Encoding: gzip before computing the SHA-256 checksum, contrary to how every other HTTP client behaves. The issue affects any Cargo registry whose CDN honours Accept-Encoding: gzip on binary responses — GitHub Pages (fronted by Fastly) is a reliable example.
Possible fixes
Suggested by my AI, I would of course love to hear other ideas:
- Bazel-side (preferred): compute SHA-256 after decompressing
Content-Encoding: gzip, consistent with other HTTP client libraries. - rules_rust: do not emit
Accept-Encoding: gzipwhen issuing crate download requests (e.g. via a--headerdownloader flag). - rules_rust: expose a per-URL or per-registry option to suppress specific request headers in the generated
http_archivecalls.
- Ngôn ngữ chính
- Starlark
- Star
- 857
- Fork
- 701
- Merge trung bình
- 4 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazelbuild/rules_rust
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfilesCó thể đã có người làm @Wito-1 đã nhận 66 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
bazelbuild/rules_rust#4309 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain conditionCó thể đã có người làm @Mattbusel đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bazelbuild/rules_rust#4266 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
rust.toolchain(strip_level = ...) is silently ignoredCó thể đã có người làm @Mattbusel đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bazelbuild/rules_rust#4223 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
bazelbuild/rules_rust#4152 · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
awaiting-response
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bazelbuild/rules_rust#3599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của bazelbuild/rules_rust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
bazelbuild/apple_support#707 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
blocky: new version 0.38.0Đang mởout-of-date
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blast/large refactor risk/low spend-dem
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
chriskelly/MusicWall#87 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
neilotoole/sq#1503 ·
Maintainer thường phản hồi trong vòng 1 ngày