From ce75297c0654f9d72de33f619cff1ff47d6d6f20 Mon Sep 17 00:00:00 2001 From: Jared Atkinson Date: Fri, 20 Nov 2026 21:17:40 -0800 Subject: [PATCH] fix: BED-10678 emit app installation events as arrays --- descriptions/nodes/GH_App.md | 2 +- descriptions/nodes/GH_AppInstallation.md | 2 +- src/openhound_github/models/app_installation.py | 9 ++++----- tests/test_enterprise_app_installation.py | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/descriptions/nodes/GH_App.md b/descriptions/nodes/GH_App.md index ac83b426..9b5993a8 100644 --- a/descriptions/nodes/GH_App.md +++ b/descriptions/nodes/GH_App.md @@ -36,7 +36,7 @@ Organization membership is established from `membersWithRole`, and enterprise me | `owner_type` | `string` | The type of the owner (e.g., `User`, `Organization`). | | `permissions` | `list[string]` | Requested app permissions in `scope:access` form. | | `registration_origin` | `string` | `tenant_owned`, `member_owned`, `third_party`, or `unknown`, based on collected ownership and membership evidence. | -| `events` | `list[string]` | JSON string of the default webhook events the app subscribes to. | +| `events` | `list[string]` | Default webhook events the app subscribes to. | | `installations_count` | `integer` | The total number of installations of this app across all organizations. | | `created_at` | `datetime` | When the app was created. | | `updated_at` | `datetime` | When the app was last updated. | diff --git a/descriptions/nodes/GH_AppInstallation.md b/descriptions/nodes/GH_AppInstallation.md index 73c88ff4..90d0f5a4 100644 --- a/descriptions/nodes/GH_AppInstallation.md +++ b/descriptions/nodes/GH_AppInstallation.md @@ -32,7 +32,7 @@ Enterprise collection includes the authenticating collector app's installation, | `repository_selection` | `string` | Whether the app has access to `all` repositories or `selected` repositories. | | `target_type` | `string` | The target type of the installation (e.g., `Organization` or `Enterprise`). | | `permissions` | `list[string]` | Permissions granted to the installation in `scope:access` form. | -| `events` | `string` | JSON string of the webhook events the app subscribes to. | +| `events` | `list[string]` | Webhook events the app subscribes to. | | `created_at` | `datetime` | When the app was installed. | | `updated_at` | `datetime` | When the installation was last updated. | | `suspended_at` | `datetime` | When the installation was suspended, if applicable. | diff --git a/src/openhound_github/models/app_installation.py b/src/openhound_github/models/app_installation.py index 88485335..0409fdfc 100644 --- a/src/openhound_github/models/app_installation.py +++ b/src/openhound_github/models/app_installation.py @@ -2,7 +2,6 @@ from datetime import datetime from typing import ClassVar -from dlt.common import json from dlt.common.libs.pydantic import DltConfig from openhound.core.asset import BaseAsset, EdgeDef, NodeDef from openhound.core.models.entries_dataclass import Edge, EdgePath, EdgeProperties @@ -35,7 +34,7 @@ class GHAppInstallationProperties(GHNodeProperties): repository_selection: Whether the app has access to `all` repositories or `selected` repositories. target_type: The target type of the installation (`Organization` or `Enterprise`). permissions: Permissions granted to the installation in `scope:access` form. - events: JSON string of the webhook events the app subscribes to. + events: Webhook events the app subscribes to. created_at: When the app was installed. updated_at: When the installation was last updated. suspended_at: When the installation was suspended, if applicable. @@ -55,7 +54,7 @@ class GHAppInstallationProperties(GHNodeProperties): repository_selection: str | None = None target_type: str | None = None permissions: list[str] | None = None - events: str | None = None + events: list[str] | None = None created_at: datetime | None = None updated_at: datetime | None = None suspended_at: datetime | None = None @@ -187,7 +186,7 @@ def as_node(self) -> GHNode: repository_selection=self.repository_selection, target_type=self.target_type, permissions=normalize_permission_declaration(self.permissions), - events=json.dumps(self.events) if self.events else None, + events=self.events, created_at=self.created_at, updated_at=self.updated_at, suspended_at=self.suspended_at, @@ -268,7 +267,7 @@ class GHAppProperties(GHNodeProperties): third_party (no internal ownership evidence), or unknown. permissions: Requested app permissions in `scope:access` form. environment_slug: The organization login or enterprise slug where the app was collected. - events: JSON string of the default webhook events the app subscribes to. + events: Default webhook events the app subscribes to. installations_count: The total number of installations of this app across all organizations. created_at: When the app was created. updated_at: When the app was last updated. diff --git a/tests/test_enterprise_app_installation.py b/tests/test_enterprise_app_installation.py index 7ba0cfcb..0c9fbcd0 100644 --- a/tests/test_enterprise_app_installation.py +++ b/tests/test_enterprise_app_installation.py @@ -42,6 +42,23 @@ def _payload(): } +@pytest.mark.parametrize("events", [["push", "repository", "workflow_job"], [], None]) +def test_installation_events_remain_arrays_in_graph_output(events): + from dataclasses import asdict + + installation = AppInstallation(**{**_payload(), "events": events}) + + output = json.loads(json.dumps(asdict(installation.as_node), default=str)) + + assert output["properties"]["events"] == events + + +def test_installation_missing_events_remain_unset(): + installation = AppInstallation(**_payload()) + + assert installation.as_node.properties.events is None + + def _ctx(): """Build independent app-JWT and enterprise-installation clients.""" ctx = SourceContext(