Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion descriptions/nodes/GH_App.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
2 changes: 1 addition & 1 deletion descriptions/nodes/GH_AppInstallation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
9 changes: 4 additions & 5 deletions src/openhound_github/models/app_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions tests/test_enterprise_app_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down