AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix(github): skip qualifier-only topics with malformed wrappers (#1282)
Arthur Andre Almeida Santosdd176d5b79db
diff --git a/changelog.d/969.fixed.md b/changelog.d/969.fixed.mdnew file mode 100644index 00000000..86b4cdeb--- /dev/null+++ b/changelog.d/969.fixed.md@@ -0,0 +1 @@+GitHub searches skip qualifier-only topics with malformed or nested wrappers instead of sending punctuation-only queries. Topics containing real search text keep their existing punctuation.diff --git a/skills/last30days/scripts/lib/github.py b/skills/last30days/scripts/lib/github.pyindex fe3e221f..f8495809 100644--- a/skills/last30days/scripts/lib/github.py+++ b/skills/last30days/scripts/lib/github.py@@ -179,7 +179,7 @@ def _compute_relevance(# the qualifier so no stray `()`/`""` residue reaches the query (issue #952).# The plain regex's boundary also accepts wrapper openers so a qualifier with# a missing closer ("(created:>2025-03-20") is still stripped rather than-# leaking into the query; only the stray opener survives, harmlessly.+# leaking into the query; qualifier-only wrapper residue is discarded below.QUALIFIER_KEYS = frozenset({"archived", "assignee", "author", "base", "closed", "comments", "commenter","created", "fork", "forks", "head", "in", "interactions", "involves", "is",@@ -220,6 +220,11 @@ def strip_search_qualifiers(text: str) -> str:"""stripped = _WRAPPED_QUALIFIER_RE.sub(" ", text)stripped = _QUALIFIER_RE.sub(" ", stripped)+ # Malformed/nested wrappers can leave only punctuation after a qualifier+ # is removed (#969). There is no subject to search in that case. Keep+ # wrappers around actual topic text, including unbalanced ones like "ai (foo".+ if stripped != text and re.fullmatch(r"[\s()\[\]\"']*", stripped):+ return ""while True:cleaned = _EMPTY_WRAPPER_RE.sub("", stripped)if cleaned == stripped:diff --git a/tests/test_github.py b/tests/test_github.pyindex a9d8ea71..6f7101ff 100644--- a/tests/test_github.py+++ b/tests/test_github.py@@ -623,11 +623,22 @@ class TestStripSearchQualifiers(unittest.TestCase):)def test_missing_closer_qualifier_still_stripped(self):- # An opener without its closer ("(created:>2025-03-20") must not leak- # the qualifier into the query: only the stray opener survives, and the- # collision class (#949) stays dead.- result = github.strip_search_qualifiers("(created:>2025-03-20")- self.assertNotIn("created:", result)+ self.assertEqual(+ github.strip_search_qualifiers("(created:>2025-03-20"), "",+ )++ def test_wrapper_cleanup_preserves_real_topic_text(self):+ for topic, expected in [+ ("ai (foo", "ai (foo"),+ ("ai (foo created:>2025-03-20", "ai (foo"),+ ("(foo) created:>2025-03-20", "(foo)"),+ ('"quoted topic" created:>2025-03-20', '"quoted topic"'),+ ("([foo created:>2025-03-20", "([foo"),+ ("(", "("),+ (")", ")"),+ ]:+ with self.subTest(topic=topic):+ self.assertEqual(github.strip_search_qualifiers(topic), expected)def test_quote_wrapped_with_space_inside_does_not_leak_qualifier(self):# '"created:>2025-03-20 abc"' has a space in the quoted value, so it isdiff --git a/tests/test_github_qualifier_only.py b/tests/test_github_qualifier_only.pyindex 29f1bff2..5607f934 100644--- a/tests/test_github_qualifier_only.py+++ b/tests/test_github_qualifier_only.py@@ -7,6 +7,8 @@ and pipeline._result_outcome_artifact mapped that error to a failed attempt.from unittest.mock import patch+import pytest+from lib import github, pipeline, schema@@ -80,3 +82,24 @@ def test_quote_wrapped_qualifier_only_topic_is_clean_no_results_not_error():assert artifact == {}assert "github" not in bundle.errors_by_sourceassert bundle.source_status["github"].state == schema.NO_RESULTS++[email protected]("topic", [+ "(created:>2025-03-20",+ "created:>2025-03-20)",+ '(("created:>2025-03-20"))',+ '[(("created:>2025-03-20"))',+ "[is:issue",+ "is:issue]",+ "(created:>2025-03-20 [stars:>1000",+ "[\u00a0created:>2025-03-20",+])+def test_malformed_wrapper_qualifier_only_topic_skips_network(topic):+ result, mock_fetch = _search(topic)+ mock_fetch.assert_not_called()+ assert result["items"] == []+ assert "error" not in result+ artifact, bundle = _bundle_from_envelope(result)+ assert artifact == {}+ assert "github" not in bundle.errors_by_source+ assert bundle.source_status["github"].state == schema.NO_RESULTS