mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
0d00b886ac
* fix(rio): surface incomplete put bodies Propagate incomplete PUT request bodies as IncompleteBody instead of allowing erasure encode to treat truncated input as a normal EOF.\n\n- mark premature EOFs in HardLimitReader with an explicit IncompleteBody error\n- preserve EOF error chains through read_full and map them to S3 IncompleteBody\n- stop erasure encode from swallowing UnexpectedEof on truncated input\n- add regression tests for reader, erasure encode, and API error mapping\n\nRefs: rustfs/backlog#654 * fix(s3): honor decoded length for aws chunked put Use x-amz-decoded-content-length for aws-chunked PutObject requests so trailer-checksum uploads are sized against the decoded payload instead of the wire-encoded content-length.\n\n- prefer decoded content length for aws-chunked put bodies\n- add a regression test covering the size selection logic\n- keeps the incomplete body fix working for truly truncated uploads while restoring checksum trailer compatibility\n\nRefs: rustfs/backlog#654 * fix(io): follow up review comments on incompletebody handling Address PR review feedback by restoring read_full's existing EOF contract, adding a dedicated read_full_or_eof helper for erasure encoding, covering nested incomplete-body error chains, and documenting plus hardening aws-chunked size selection.\n\n- keep read_full returning early EOF on empty reads\n- use read_full_or_eof only in erasure encoding paths\n- detect aws-chunked via content-encoding or transfer-encoding\n- add nested error-chain and aws-chunked regression tests\n\nRefs: rustfs/backlog#654 * fix(rio): surface incomplete put bodies Propagate incomplete PUT request bodies as IncompleteBody instead of allowing erasure encode to treat truncated input as a normal EOF.\n\n- mark premature EOFs in HardLimitReader with an explicit IncompleteBody error\n- preserve EOF error chains through read_full and map them to S3 IncompleteBody\n- stop erasure encode from swallowing UnexpectedEof on truncated input\n- add regression tests for reader, erasure encode, and API error mapping\n\nRefs: rustfs/backlog#654 * fix(s3): honor decoded length for aws chunked put Use x-amz-decoded-content-length for aws-chunked PutObject requests so trailer-checksum uploads are sized against the decoded payload instead of the wire-encoded content-length.\n\n- prefer decoded content length for aws-chunked put bodies\n- add a regression test covering the size selection logic\n- keeps the incomplete body fix working for truly truncated uploads while restoring checksum trailer compatibility\n\nRefs: rustfs/backlog#654 * fix(io): follow up review comments on incompletebody handling Address PR review feedback by restoring read_full's existing EOF contract, adding a dedicated read_full_or_eof helper for erasure encoding, covering nested incomplete-body error chains, and documenting plus hardening aws-chunked size selection.\n\n- keep read_full returning early EOF on empty reads\n- use read_full_or_eof only in erasure encoding paths\n- detect aws-chunked via content-encoding or transfer-encoding\n- add nested error-chain and aws-chunked regression tests\n\nRefs: rustfs/backlog#654 * fix(rio): reject bytes beyond hard limit * fix(ecstore): reject zero-sized erasure blocks
81 lines
2.6 KiB
Rust
81 lines
2.6 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// SHA256 mismatch error - when content SHA256 does not match what was sent from client
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Bad sha256: Expected {expected_sha256} does not match calculated {calculated_sha256}")]
|
|
pub struct Sha256Mismatch {
|
|
pub expected_sha256: String,
|
|
pub calculated_sha256: String,
|
|
}
|
|
|
|
/// Bad digest error - Content-MD5 you specified did not match what we received
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Bad digest: Expected {expected_md5} does not match calculated {calculated_md5}")]
|
|
pub struct BadDigest {
|
|
pub expected_md5: String,
|
|
pub calculated_md5: String,
|
|
}
|
|
|
|
/// Size too small error - reader size too small
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Size small: got {got}, want {want}")]
|
|
pub struct SizeTooSmall {
|
|
pub want: i64,
|
|
pub got: i64,
|
|
}
|
|
|
|
/// Size too large error - reader size too large
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Size large: got {got}, want {want}")]
|
|
pub struct SizeTooLarge {
|
|
pub want: i64,
|
|
pub got: i64,
|
|
}
|
|
|
|
/// Size mismatch error
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Size mismatch: got {got}, want {want}")]
|
|
pub struct SizeMismatch {
|
|
pub want: i64,
|
|
pub got: i64,
|
|
}
|
|
|
|
/// Checksum mismatch error - when content checksum does not match what was sent from client
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Bad checksum: Want {want} does not match calculated {got}")]
|
|
pub struct ChecksumMismatch {
|
|
pub want: String,
|
|
pub got: String,
|
|
}
|
|
|
|
/// Request body ended before the declared size was fully read.
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("Incomplete body: {remaining} bytes were still expected")]
|
|
pub struct IncompleteBody {
|
|
pub remaining: i64,
|
|
}
|
|
|
|
/// Invalid checksum error
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
#[error("invalid checksum")]
|
|
pub struct InvalidChecksum;
|
|
|
|
/// Check if an error is a checksum mismatch
|
|
pub fn is_checksum_mismatch(err: &(dyn std::error::Error + 'static)) -> bool {
|
|
err.downcast_ref::<ChecksumMismatch>().is_some()
|
|
}
|