From 37cabc47d31509b3a8eab005f4ca4ba67f1a9641 Mon Sep 17 00:00:00 2001 From: Teknium Date: Wed, 25 Mar 2026 16:09:27 -0700 Subject: [PATCH] test(skills): add regression tests for null metadata frontmatter Covers the case where a SKILL.md has `metadata:` (null) or `metadata.hermes:` (null), which caused an AttributeError before the fix in d218cf91. Made-with: Cursor --- tests/agent/test_prompt_builder.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py index a778cbd81..13eaedb3d 100644 --- a/tests/agent/test_prompt_builder.py +++ b/tests/agent/test_prompt_builder.py @@ -878,3 +878,32 @@ class TestBuildSkillsSystemPromptConditional: ) result = build_skills_system_prompt() assert "duckduckgo" in result + + def test_null_metadata_does_not_crash(self, monkeypatch, tmp_path): + """Regression: metadata key present but null should not AttributeError.""" + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) + skill_dir = tmp_path / "skills" / "general" / "safe-skill" + skill_dir.mkdir(parents=True) + # YAML `metadata:` with no value parses as {"metadata": None} + (skill_dir / "SKILL.md").write_text( + "---\nname: safe-skill\ndescription: Survives null metadata\nmetadata:\n---\n" + ) + result = build_skills_system_prompt( + available_tools=set(), + available_toolsets=set(), + ) + assert "safe-skill" in result + + def test_null_hermes_under_metadata_does_not_crash(self, monkeypatch, tmp_path): + """Regression: metadata.hermes present but null should not crash.""" + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) + skill_dir = tmp_path / "skills" / "general" / "nested-null" + skill_dir.mkdir(parents=True) + (skill_dir / "SKILL.md").write_text( + "---\nname: nested-null\ndescription: Null hermes key\nmetadata:\n hermes:\n---\n" + ) + result = build_skills_system_prompt( + available_tools=set(), + available_toolsets=set(), + ) + assert "nested-null" in result