Skip to content

The agent that grows with you

fix(skills): a malformed ClawHub lock row no longer empties the installed map

Austin Pickett27e6375b413c
diff --git a/tests/hermes_cli/test_installed_hub_identifiers.py b/tests/hermes_cli/test_installed_hub_identifiers.py
index da85b976358..2e506c5a800 100644
--- a/tests/hermes_cli/test_installed_hub_identifiers.py
+++ b/tests/hermes_cli/test_installed_hub_identifiers.py
@@ -58,6 +58,17 @@ def test_an_exact_lock_id_beats_a_clawhub_alias():
assert _installed_hub_identifiers()["clawhub/foo"]["name"] == "foo"
+def test_a_malformed_clawhub_row_does_not_hide_the_other_installs():
+ # A hand-edited lock can hold a non-string identifier. It used to reach the
+ # ClawHub parser, raise, and leave the whole map empty.
+ HubLockFile().save({"version": 1, "installed": {
+ "broken": {"source": "clawhub", "identifier": 123, "install_path": "broken"},
+ "arxiv": {"source": "official", "identifier": "official/research/arxiv",
+ "install_path": "arxiv"}}})
+
+ assert _installed_hub_identifiers()["official/research/arxiv"]["name"] == "arxiv"
+
+
def test_hub_search_returns_the_card_id_a_clawhub_hit_is_found_under(monkeypatch):
# Index-backed results carry ClawHub's bare slug. The map answers to clawhub/<slug>,
# which the dashboard derives from the hit's source (web/src/lib/skill-hub-installed.ts).
diff --git a/tools/skills_hub_clawhub.py b/tools/skills_hub_clawhub.py
index 2ac22676f12..040e7aacfc0 100644
--- a/tools/skills_hub_clawhub.py
+++ b/tools/skills_hub_clawhub.py
@@ -235,10 +235,11 @@ class ClawHubSource(GuardedFetchMixin, SkillSource):
return slug, owner
@classmethod
- def catalog_identifier(cls, identifier: str) -> Optional[str]:
+ def catalog_identifier(cls, identifier: Any) -> Optional[str]:
"""``clawhub/<slug>``, the owner-less id a catalog card installs, for any ClawHub
- ``identifier`` (``fetch`` records ``@owner/slug``). None when it is not a ClawHub id."""
- parsed = cls._parse_identifier(identifier)
+ ``identifier`` (``fetch`` records ``@owner/slug``). None when it is not a ClawHub id,
+ including a non-string value from a hand-edited lock."""
+ parsed = cls._parse_identifier(identifier) if isinstance(identifier, str) else None
return f"clawhub/{parsed[0]}" if parsed else None
def fetch(self, identifier: str) -> Optional[SkillBundle]: