diff --git a/keep/api/core/db.py b/keep/api/core/db.py index 7fd835adc..edad96fc7 100644 --- a/keep/api/core/db.py +++ b/keep/api/core/db.py @@ -3014,10 +3014,12 @@ def get_incidents_meta_for_tenant(tenant_id: str) -> dict: if not results: return {} + assignees, sources, affected_services = results + return { - "assignees": list(filter(bool, results.assignees)), - "sources": list(filter(bool, results.sources)), - "services": list(filter(bool, results.affected_services)), + "assignees": list(filter(bool, assignees)) if assignees else [], + "sources": list(filter(bool, sources)) if sources else [], + "services": list(filter(bool, affected_services)) if affected_services else [], } return {} @@ -4628,4 +4630,4 @@ def set_last_alert( ) session.add(last_alert) - transaction.commit() \ No newline at end of file + transaction.commit() diff --git a/tests/test_incidents.py b/tests/test_incidents.py index 1d1de3fb9..4ecf89b89 100644 --- a/tests/test_incidents.py +++ b/tests/test_incidents.py @@ -859,4 +859,4 @@ def test_cross_tenant_exposure_issue_2768(db_session, create_alert): ) assert incident_tenant_2.alerts_count == 1 assert total_incident_tenant_2_alerts == 1 - assert len(incident_tenant_2_alerts) == 1 \ No newline at end of file + assert len(incident_tenant_2_alerts) == 1