rustfs/rustfs · error · std::io::Error

SHA256 mismatch

Error message

SHA256 mismatch

What it means

Fires when the streamed body finishes and the SHA256 computed by the content hasher differs from the expected value, or the hasher errors at finish. Guards integrity of chunked/trailing-checksum uploads at read completion.

Source

Thrown at crates/rio/src/hash_reader.rs:563

                        error!("SHA256 hasher write error, error={:?}", e);
                        return Poll::Ready(Err(std::io::Error::other(e)));
                    }

                    // Update content hasher
                    if let Some(hasher) = this.content_hasher
                        && let Err(e) = hasher.write_all(data)
                    {
                        return Poll::Ready(Err(std::io::Error::other(e)));
                    }
                }

                if filled == 0 && !*this.checksum_on_finish {
                    // check SHA256
                    if let (Some(hasher), Some(expected_sha256)) = (this.content_sha256_hasher, this.content_sha256) {
                        let sha256 = hex_simd::encode_to_string(hasher.finalize(), hex_simd::AsciiCase::Lower);
                        if sha256 != *expected_sha256 {
                            error!("SHA256 mismatch, expected={:?}, actual={:?}", expected_sha256, sha256);
                            return Poll::Ready(Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "SHA256 mismatch")));
                        }
                    }

                    // check content hasher
                    if let (Some(hasher), Some(expected_content_hash)) = (this.content_hasher, this.content_hash) {
                        if expected_content_hash.checksum_type.trailing()
                            && let Some(trailer) = this.trailer_s3s.as_ref()
                            && let Some(Some(checksum_str)) = trailer.read(|headers| {
                                expected_content_hash
                                    .checksum_type
                                    .key()
                                    .and_then(|key| headers.get(key).and_then(|value| value.to_str().ok().map(|s| s.to_string())))
                            })
                        {
                            expected_content_hash.encoded = checksum_str;
                            expected_content_hash.raw = general_purpose::STANDARD
                                .decode(&expected_content_hash.encoded)
                                .map_err(|_| std::io::Error::other("Invalid base64 checksum"))?;

View on GitHub (pinned to 35af688cd9)

Solutions

  1. Retry the upload; transit corruption is often transient
  2. Fix client body mutation after signing
  3. Verify no middleware rewrites the payload
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/rio/src/hash_reader.rs:563 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rustfs/rustfs@35af688cd9 (2026-08-20). Data as JSON: /api/errors/c8c7bf1f70559883. Report an issue: GitHub.