From e7b92741908e75f4932643b39e375723839e0483 Mon Sep 17 00:00:00 2001 From: lichen2015 Date: Fri, 7 Aug 2026 16:31:03 +0800 Subject: [PATCH] fix(stat): return text/markdown for .md files regardless of OS mime registry (#433) On macOS, mimetypes.guess_type() may not recognize .md files, causing stat to report application/octet-stream and breaking test assertions. Explicitly map .md files to text/markdown so the behavior is stable across platforms. --- reme/steps/file_io/stat.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reme/steps/file_io/stat.py b/reme/steps/file_io/stat.py index cb20b7b8..06ba4d92 100644 --- a/reme/steps/file_io/stat.py +++ b/reme/steps/file_io/stat.py @@ -64,8 +64,11 @@ class StatStep(BaseStep): } if target.is_file(): payload["size"] = st.st_size - payload["mime"] = mimetypes.guess_type(target.name)[0] or "application/octet-stream" - if target.suffix == ".md": + is_md = target.suffix.lower() == ".md" + payload["mime"] = ( + "text/markdown" if is_md else (mimetypes.guess_type(target.name)[0] or "application/octet-stream") + ) + if is_md: try: meta = dict(frontmatter.loads(target.read_text(encoding="utf-8")).metadata) except Exception: