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
+28
View File
@@ -160,6 +160,8 @@ pub struct AuditEntry {
pub api: ApiDetails,
#[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")]
pub remote_host: Option<String>,
// Historical external audit contract: keep `requestID` instead of normalizing
// this field to `request_id` or `request-id`.
#[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
pub request_id: Option<String>,
#[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")]
@@ -315,3 +317,29 @@ impl AuditEntryBuilder {
self.0
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::Value;
#[test]
fn audit_entry_serializes_historical_request_id_field_name() {
let entry = AuditEntryBuilder::new(
"1",
EventName::ObjectCreatedPut,
"s3",
ApiDetailsBuilder::new()
.name("PutObject")
.status("OK")
.status_code(200)
.build(),
)
.request_id("req-audit-123")
.build();
let value = serde_json::to_value(entry).expect("audit entry should serialize");
assert_eq!(value["requestID"], Value::String("req-audit-123".to_string()));
assert!(value.get("request_id").is_none(), "historical audit contract must not expose request_id");
}
}