The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(skills): seam the sitemap-shard retry test on the hub guarded GET
teknium1d457e7f039ee
diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.pyindex 32e759998ff..b7631b4d73c 100644--- a/tests/tools/test_skills_hub.py+++ b/tests/tools/test_skills_hub.py@@ -258,23 +258,29 @@ class TestSkillsShSource:@patch("tools.skills_hub._write_index_cache")@patch("tools.skills_hub._read_index_cache", return_value=None)def test_sitemap_catalog_retries_failed_shard_and_never_caches_partial(- self, _mock_read_cache, mock_write_cache, _mock_sleep,+ self, _mock_read_cache, mock_write_cache, _mock_sleep, monkeypatch,):"""A per-skill sitemap shard that keeps failing is a hole in the catalog, not anempty shard: retry it, and never publish the partial slice to the shared cache."""+ monkeypatch.setattr("tools.skills_hub.is_safe_url", lambda _url: True)+ monkeypatch.setattr("tools.skills_hub.check_website_access", lambda _url: None)+ monkeypatch.setattr("tools.skills_hub_skillssh._cached_metas", lambda _key: None)+ monkeypatch.setattr("tools.skills_hub_skillssh._cache_metas", lambda _key, _metas: None)index = ("<sitemapindex><sitemap><loc>https://www.skills.sh/sitemap-skills-0.xml</loc></sitemap>""<sitemap><loc>https://www.skills.sh/sitemap-skills-1.xml</loc></sitemap></sitemapindex>")shard0 = "<urlset><url><loc>https://www.skills.sh/o/r/skill-a</loc></url></urlset>"calls: List[str] = []- def fake_get_text(url, **kwargs):+ def fake_get(url, *, timeout, headers=None):calls.append(url)if url.endswith("sitemap.xml"):- return index- return shard0 if url.endswith("sitemap-skills-0.xml") else None+ return MagicMock(status_code=200, headers={}, text=index)+ if url.endswith("sitemap-skills-0.xml"):+ return MagicMock(status_code=200, headers={}, text=shard0)+ return MagicMock(status_code=503, headers={}, text="")- with patch("tools.skills_hub_skillssh._get_text", side_effect=fake_get_text):- results = self._source()._sitemap_catalog(0)+ monkeypatch.setattr("tools.skills_hub._ssrf_safe_http_get", fake_get)+ results = self._source()._sitemap_catalog(0)assert [m.identifier for m in results] == ["skills-sh/o/r/skill-a"]assert calls.count("https://www.skills.sh/sitemap-skills-1.xml") == SkillSource.CATALOG_PAGE_RETRIESdiff --git a/tools/skills_hub_skillssh.py b/tools/skills_hub_skillssh.pyindex a5cd8cd7777..7a3fe96f3f5 100644--- a/tools/skills_hub_skillssh.py+++ b/tools/skills_hub_skillssh.py@@ -139,7 +139,7 @@ class SkillsShSource(SkillSource):return self._featured_skills(limit)# Step 2: collect canonical "owner/repo/skill" IDs from each sitemap. A shard- # ``_get_text`` returns None for is a hole, not an empty shard: retry it, and+ # ``_xml`` returns None for is a hole, not an empty shard: retry it, and# if it stays dark return the partial slice without publishing it to the cache.seen, results, partial = set(), [], Falsefor sitemap_url in skill_sitemap_urls: