refactor(request-id): align contracts and lock field names (#3454)

* refactor(request-id): align header log and trace contracts

* test(contract): lock external request-id field names

* chore(deps): drop unused rustfs-ecstore links

Co-Authored-By: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-06-15 01:59:11 +08:00
committed by GitHub
parent efaf07d323
commit 036741cb1c
12 changed files with 226 additions and 65 deletions
@@ -36,6 +36,8 @@ pub struct ErrorResponse {
pub bucket_name: String,
pub key: String,
pub resource: String,
// External S3-style error response contract: keep `RequestId`.
#[serde(rename = "RequestId")]
pub request_id: String,
pub host_id: String,
pub region: String,
@@ -302,3 +304,29 @@ pub fn err_api_not_supported(message: &str) -> ErrorResponse {
..Default::default()
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::Value;
#[test]
fn error_response_serializes_request_id_as_pascal_case_contract() {
let response = ErrorResponse {
code: S3ErrorCode::InvalidArgument,
message: "bad request".to_string(),
bucket_name: "bucket".to_string(),
key: "key".to_string(),
resource: "/bucket/key".to_string(),
request_id: "req-xml-123".to_string(),
host_id: "host-1".to_string(),
region: "us-east-1".to_string(),
server: "rustfs".to_string(),
status_code: StatusCode::BAD_REQUEST,
};
let value = serde_json::to_value(response).expect("error response should serialize");
assert_eq!(value["RequestId"], Value::String("req-xml-123".to_string()));
assert!(value.get("request_id").is_none(), "external error contract must not expose request_id");
}
}