Skip to content

The agent that grows with you

fix(platform): host summary reports the macOS version on a Mac

alt-glitch1e92db235f68
diff --git a/hermes_platform/host/summary.py b/hermes_platform/host/summary.py
index 419dd63c071..fd6781533ef 100644
--- a/hermes_platform/host/summary.py
+++ b/hermes_platform/host/summary.py
@@ -147,6 +147,11 @@ def _machine_kind(os_family: str, spark: bool) -> str:
return {"darwin": "Mac", "win32": "PC"}.get(os_family, "computer")
+def _os_release(os_family: str) -> str:
+ # On a Mac platform.release() is the Darwin kernel version (25.x), not the macOS version (26.x).
+ return (platform.mac_ver()[0] if os_family == "darwin" else "") or platform.release()
+
+
@functools.cache
def summary() -> dict:
"""This machine and account as measured. ``machine`` leaves out a key that was not measured;
@@ -156,7 +161,7 @@ def summary() -> dict:
spark = is_spark(os_family, arch, gpu, cpu)
machine = {
"os_family": os_family,
- "os_release": platform.release(),
+ "os_release": _os_release(os_family),
"native_arch": arch,
"cpu_model": cpu,
"ram_gb": round(ram / 2**30) if ram else None,
diff --git a/tests/hermes_platform/test_host_summary.py b/tests/hermes_platform/test_host_summary.py
index 0566e85b357..a723a5b5c55 100644
--- a/tests/hermes_platform/test_host_summary.py
+++ b/tests/hermes_platform/test_host_summary.py
@@ -70,6 +70,18 @@ def test_a_login_handle_is_never_offered_as_the_name(machine, monkeypatch, full)
assert machine()["full_name"] is None
[email protected](("os_family", "mac_ver", "release"), [
+ ("darwin", "26.0.1", "26.0.1"),
+ ("darwin", "", "25.0.0"), # no macOS version reported: fall back to the kernel release
+ ("linux", "26.0.1", "25.0.0"),
+])
+def test_os_release_is_the_macos_version_on_a_mac(machine, monkeypatch, os_family, mac_ver, release):
+ monkeypatch.setattr(summary.platform, "mac_ver", lambda: (mac_ver, ("", "", ""), ""))
+ monkeypatch.setattr(summary.platform, "release", lambda: "25.0.0")
+
+ assert machine(os_family=os_family)["machine"]["os_release"] == release
+
+
def test_cached_per_process(machine, monkeypatch):
first = machine()
monkeypatch.setattr(facts, "os_family", lambda: "darwin")