From 37b292d1ccdd5bcc4fe4d965162e1b6db84bf671 Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 17 Nov 2026 02:43:02 +0000 Subject: [PATCH 1/2] Reduce no-match automation telemetry Co-authored-by: openhands --- openhands/automation/ingest.py | 27 +++++++++++++------------ tests/test_ingest.py | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/openhands/automation/ingest.py b/openhands/automation/ingest.py index c80b619b..a0d75d0a 100644 --- a/openhands/automation/ingest.py +++ b/openhands/automation/ingest.py @@ -269,20 +269,21 @@ async def accept_event( org_id, ) pending_telemetry: list[tuple[str, dict[str, Any]]] = [] - pending_telemetry.append( - ( - "automation_event_matched", - { - "properties": { - "event_source": source, - "event_key": event.event_key, - "org_id": str(org_id), - "candidate_count": len(automations), - "matched_count": len(matched), - } - }, + if matched: + pending_telemetry.append( + ( + "automation_event_matched", + { + "properties": { + "event_source": source, + "event_key": event.event_key, + "org_id": str(org_id), + "candidate_count": len(automations), + "matched_count": len(matched), + } + }, + ) ) - ) event_parent_span_context = current_span_context() diff --git a/tests/test_ingest.py b/tests/test_ingest.py index 83beff88..2c047163 100644 --- a/tests/test_ingest.py +++ b/tests/test_ingest.py @@ -680,6 +680,43 @@ async def test_accept_event_telemetry_needs_a_session_source( assert captured_telemetry == [] +@pytest.mark.asyncio +async def test_accept_event_skips_product_telemetry_when_nothing_matches( + org_id: uuid.UUID, + async_session, + async_session_factory, + slack_payload: dict, + mock_authenticated_user, + captured_telemetry: list[str], +): + async_session.add( + make_automation( + org_id, + mock_authenticated_user.user_id, + {"type": "event", "source": "slack", "on": "message"}, + ) + ) + await async_session.commit() + + result = await accept_event( + org_id, + AcceptedEvent( + source="slack", + event_key="app_mention", + payload=slack_payload, + ), + async_session, + session_factory=async_session_factory, + ) + + assert result.matched == 0 + assert captured_telemetry == [] + + events = await fetch_events(async_session) + assert len(events) == 1 + assert events[0].matched_count == 0 + + @pytest.mark.asyncio async def test_accepted_event_defaults(): """Only `source` and `event_key` are required.""" From a710ca1fc4c7d18accc567cd50fb2de271c5ad06 Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 17 Nov 2026 23:25:29 +0000 Subject: [PATCH 2/2] fix: avoid duplicate migration revision Co-authored-by: openhands --- ...col_options.py => 039_add_webhook_protocol_options.py} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename migrations/versions/{038_add_webhook_protocol_options.py => 039_add_webhook_protocol_options.py} (89%) diff --git a/migrations/versions/038_add_webhook_protocol_options.py b/migrations/versions/039_add_webhook_protocol_options.py similarity index 89% rename from migrations/versions/038_add_webhook_protocol_options.py rename to migrations/versions/039_add_webhook_protocol_options.py index 3de354fd..ebe7caef 100644 --- a/migrations/versions/038_add_webhook_protocol_options.py +++ b/migrations/versions/039_add_webhook_protocol_options.py @@ -1,7 +1,7 @@ """Add optional body delivery IDs, source admission and acknowledgement profiles. -Revision ID: 038 -Revises: 037 +Revision ID: 039 +Revises: 038 """ from collections.abc import Sequence @@ -10,8 +10,8 @@ from alembic import op -revision: str = "038" -down_revision: str = "037" +revision: str = "039" +down_revision: str = "038" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None