fix(replication): harden resync and MRF recovery (#5694)

* fix(replication): harden resync and MRF recovery

* fix(replication): correct MRF validation regressions

* fix(replication): address CI validation failures

* fix(heal): initialize decode error in merge test
This commit is contained in:
cxymds
2026-08-04 21:40:50 +08:00
committed by GitHub
parent 93fcd6b6b5
commit eb87bb1faf
11 changed files with 1004 additions and 715 deletions
+1 -3
View File
@@ -777,9 +777,7 @@ impl Operation for ReplicationDiffHandler {
// Optional prefix can be supplied either as a query parameter (MinIO
// clients) or, for RustFS clients, as a small JSON body.
let mut prefix = queries.get("prefix").cloned().unwrap_or_default();
let body = read_compatible_admin_body(req.input, MAX_ADMIN_REQUEST_BODY_SIZE, req.uri.path(), &cred.secret_key)
.await
.unwrap_or_default();
let body = read_compatible_admin_body(req.input, MAX_ADMIN_REQUEST_BODY_SIZE, req.uri.path(), &cred.secret_key).await?;
if prefix.is_empty() && !body.trim_ascii().is_empty() {
match serde_json::from_slice::<ReplicationDiffRequest>(&body) {
Ok(parsed) => prefix = parsed.prefix,
@@ -1447,3 +1447,29 @@ fn test_replication_set_remote_target_compat_contract() {
"set-remote-target should not re-encrypt ARN success responses"
);
}
#[test]
fn test_replication_diff_body_read_errors_are_not_ignored() {
let replication_src = include_str!("handlers/replication.rs");
let handler_block = extract_block_between_markers(
replication_src,
"impl Operation for ReplicationDiffHandler",
"/// Failed-replication totals for one remote target",
);
assert!(
handler_block.contains("read_compatible_admin_body("),
"replication diff must read the optional body through the compatible admin payload reader"
);
let body_read_block =
extract_block_between_markers(handler_block, "let body = read_compatible_admin_body(", "if prefix.is_empty()");
assert!(
body_read_block.contains(".await?;"),
"replication diff must fail closed when body read or MinIO-compatible decryption fails"
);
assert!(
!body_read_block.contains(".unwrap_or_default()"),
"replication diff must not silently treat body read/decryption failures as an empty request"
);
}