Skip to content

fix: align stat metadata content-type output with mc#48

Merged
overtrue merged 1 commit intomainfrom
fix/issue-46-stat-content-type
Mar 10, 2026
Merged

fix: align stat metadata content-type output with mc#48
overtrue merged 1 commit intomainfrom
fix/issue-46-stat-content-type

Conversation

@overtrue
Copy link
Contributor

@overtrue overtrue commented Mar 9, 2026

Summary

This PR fixes rc stat output parity with mc stat for object metadata display.

Fixes #46.

Problem

When running rc stat for an object, the output showed:

  • Type : text/plain (MIME type in the Type field)
  • no dedicated Metadata section containing Content-Type

Issue #46 reports that Content-Type should be shown in metadata output similarly to mc stat.

Root Cause

stat human-readable formatting treated content_type as the Type field and only rendered user-defined metadata (x-amz-meta-*) lines, so Content-Type was never emitted as metadata.

Changes

  • Added build_display_metadata() to compose sorted metadata lines for display.
  • Mapped object type explicitly as Type : file in human-readable output.
  • Added a Metadata section in human-readable output.
  • Included Content-Type inside the metadata display section.
  • Kept JSON output behavior unchanged.
  • Added unit test: test_build_display_metadata_includes_content_type.

Verification

Reproduction (before fix)

Using Docker RustFS latest:

  1. docker compose -f docker/docker-compose.yml up -d rustfs
  2. cargo run -- alias set local http://localhost:9000 accesskey secretkey
  3. cargo run -- mb local/issue46-bucket
  4. cargo run -- cp /tmp/issue46.txt local/issue46-bucket/issue46.txt
  5. cargo run -- stat local/issue46-bucket/issue46.txt

Observed before fix:

  • Type : text/plain
  • no Metadata section / no Content-Type metadata line

After fix

Now output includes:

  • Type : file
  • Metadata :
  • Content-Type : text/plain

Quality Gates

  • cargo fmt --all --check
  • cargo clippy --workspace -- -D warnings
  • cargo test --workspace

All passed.

Similar Issue Scan

Searched other CLI commands for comparable content_type display bugs; no additional stat-like human-readable metadata formatting paths requiring fixes were found.

Copilot AI review requested due to automatic review settings March 9, 2026 17:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the rc stat CLI command’s human-readable output to match mc stat expectations by moving Content-Type into a dedicated metadata display section and ensuring the Type field reflects the object kind rather than the MIME type.

Changes:

  • Added build_display_metadata() to compose sorted, human-readable metadata (including Content-Type plus X-Amz-Meta-* entries).
  • Changed human-readable Type output from MIME type to a fixed object kind (file) and introduced a Metadata section.
  • Added a unit test verifying build_display_metadata() includes Content-Type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overtrue overtrue merged commit 210c415 into main Mar 10, 2026
19 checks passed
@overtrue overtrue deleted the fix/issue-46-stat-content-type branch March 10, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The metadata returned by rc stat does not include Content Type in the same way mc stat does

2 participants