Conversation
There was a problem hiding this comment.
Pull request overview
Fixes rc stat metadata composition so Content-Type is included in the Metadata section (matching expectations from issue #46), while also normalizing displayed/serialized custom metadata keys to X-Amz-Meta-*.
Changes:
- Added
normalize_metadata()to combineContent-Typeplus custom metadata into a normalized, sortedBTreeMap. - Updated both human and JSON
statoutput to use the normalized metadata set (and to print aMetadatagroup in human output). - Added unit tests covering
Content-Typeinclusion and custom metadata key normalization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let mut sorted: BTreeMap<_, _> = meta.iter().collect(); | ||
| for (key, value) in &mut sorted { | ||
| out.insert( | ||
| format!("X-Amz-Meta-{}", capitalize_meta_key(key)), | ||
| (*value).clone(), |
There was a problem hiding this comment.
normalize_metadata builds an intermediate sorted BTreeMap (meta.iter().collect()) and iterates it mutably, but the final out is already a BTreeMap (deterministic sorting). Consider iterating meta directly and inserting into out (with an explicit owned conversion like to_owned() for values) and avoid &mut iteration to keep this helper simpler.
| let mut sorted: BTreeMap<_, _> = meta.iter().collect(); | |
| for (key, value) in &mut sorted { | |
| out.insert( | |
| format!("X-Amz-Meta-{}", capitalize_meta_key(key)), | |
| (*value).clone(), | |
| for (key, value) in meta { | |
| out.insert( | |
| format!("X-Amz-Meta-{}", capitalize_meta_key(key)), | |
| value.to_owned(), |
| if let Some(metadata) = | ||
| normalize_metadata(info.content_type.as_deref(), info.metadata.as_ref()) | ||
| { |
There was a problem hiding this comment.
normalize_metadata(...) is recomputed in the human-output branch even though the JSON branch already computes it. Consider computing the normalized metadata once per object and reusing it for both output modes to avoid duplication and potential drift.
Summary
rc statmetadata composition soContent-Typeis included under theMetadatasectionX-Amz-Meta-*)metadatapayload with the same normalized metadata setReproduction
Issue: #46
Using Docker (
rustfs/rc:latest+ MinIO),rc statoutput showedType: text/plainbut did not includeContent-Typein metadata.Changes
normalize_metadata()incrates/cli/src/commands/stat.rsContent-Typewhen building metadata for both human and JSON outputMetadatagroup in human output and include normalized metadata entriesVerification
cargo fmt --allcargo clippy --workspace --all-targets -- -D warningscargo test --workspacerustfs/rc:latest(reproduced missing metadata content-type)MetadataincludesContent-Type)Risk
statoutput formatting/serializationmetadatanow includes normalized header-style keysRelated