Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(review_hog): allow the label trigger on ai-gateway (#108817)

Charles Vien1784b9ce6b25
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.md
index 6b4c7f311904..46b59927b6dd 100644
--- a/products/review_hog/ARCHITECTURE.md
+++ b/products/review_hog/ARCHITECTURE.md
@@ -708,7 +708,7 @@ See [DECISIONS.md](./DECISIONS.md) for the "reuse the leaf, own the model" bound
Existing automation routing and its configuration remain separate from the flag.
**Triggers.** Six entry points feed the same per-PR `ReviewPRQueueWorkflow`: the `run_review` CLI (manual / eval), the
-`reviewhog` **label** on a `PostHog/posthog` PR (a thin GitHub Action → `POST /api/review_hog/trigger`), a **UI**
+`reviewhog` **label** on a `PostHog/posthog` or `PostHog/ai-gateway` PR (a thin GitHub Action → `POST /api/review_hog/trigger`), a **UI**
"Review this PR" field in the Code review scene (any installation-accessible PR; its split button's `run_mode`
also carries the review-without-resolving and resolve-only variants; the configured internal project also shows
**Flash**, which pins resolution off), an **inbox** trigger (a
diff --git a/products/review_hog/backend/api/trigger.py b/products/review_hog/backend/api/trigger.py
index c66366ac88e9..8a4df893a4c8 100644
--- a/products/review_hog/backend/api/trigger.py
+++ b/products/review_hog/backend/api/trigger.py
@@ -23,8 +23,7 @@ from products.review_hog.backend.temporal.types import TRIGGER_LABEL, resolve_pr
logger = logging.getLogger(__name__)
-# v1 scope: ReviewHog only runs against the main PostHog monorepo. Matched case-insensitively.
-ALLOWED_REPOS = {"posthog/posthog"}
+ALLOWED_REPOS = {"posthog/posthog", "posthog/ai-gateway"}
class ReviewHogTriggerRequestSerializer(serializers.Serializer):
diff --git a/products/review_hog/backend/tests/test_trigger_api.py b/products/review_hog/backend/tests/test_trigger_api.py
index f4d70de77ca2..c693471b3d97 100644
--- a/products/review_hog/backend/tests/test_trigger_api.py
+++ b/products/review_hog/backend/tests/test_trigger_api.py
@@ -90,27 +90,42 @@ class TestReviewHogTriggerApi(APIBaseTest):
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
mock_start.assert_not_called()
+ @parameterized.expand(
+ [
+ ("other_org", "evil/repo"),
+ ("allowlisted_name_other_org", "evil/ai-gateway"),
+ ("allowlisted_prefix", "PostHog/ai-gateway-fork"),
+ ]
+ )
@patch(_START, return_value="wf-1")
- def test_disallowed_repo_rejected(self, mock_start):
+ def test_disallowed_repo_rejected(self, _name, repo, mock_start):
resp = self.client.post(
TRIGGER_URL,
- {"repo": "evil/repo", "pr_number": 1},
+ {"repo": repo, "pr_number": 1},
format="json",
HTTP_AUTHORIZATION="Bearer secret-token",
)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
mock_start.assert_not_called()
+ @parameterized.expand(
+ [
+ ("posthog_lowercase", "posthog/posthog"),
+ ("ai_gateway", "PostHog/ai-gateway"),
+ ("ai_gateway_lowercase", "posthog/ai-gateway"),
+ ]
+ )
@patch(_START, return_value="wf-1")
- def test_allowlist_is_case_insensitive(self, mock_start):
+ def test_allowlisted_repo_accepted(self, _name, repo, mock_start):
resp = self.client.post(
TRIGGER_URL,
- {"repo": "posthog/posthog", "pr_number": 7},
+ {"repo": repo, "pr_number": 7},
format="json",
HTTP_AUTHORIZATION="Bearer secret-token",
)
self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED, resp.content)
mock_start.assert_called_once()
+ self.assertEqual(mock_start.call_args.kwargs["pr_url"], f"https://github.com/{repo}/pull/7")
@override_settings(REVIEWHOG_TEAM_IDS=[])
@patch(_START, return_value="wf-1")