From 992b23b9b308fa63704cd876e83a2915dfa9b0d1 Mon Sep 17 00:00:00 2001 From: Bertrand Caplet Date: Mon, 18 Aug 2025 18:28:06 -0400 Subject: [PATCH 1/3] fixes #5259 --- keep/api/core/db.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/keep/api/core/db.py b/keep/api/core/db.py index 23d0efc535..f232f2eacc 100644 --- a/keep/api/core/db.py +++ b/keep/api/core/db.py @@ -1395,15 +1395,20 @@ def batch_enrich( } # Prepare bulk update for existing enrichments - to_update = [] to_create = [] audit_entries = [] for fingerprint in fingerprints: existing = existing_enrichments.get(fingerprint) - if existing: - to_update.append(existing.id) + # AlertEnrichment exist, update and merge enrichments + new_enrichment_data = {**existing.enrichments, **enrichments} + stmt = ( + update(AlertEnrichment) + .where(AlertEnrichment.id == existing.id) + .values(enrichments=new_enrichment_data) + ) + session.execute(stmt) else: # For new entries to_create.append( @@ -1425,15 +1430,6 @@ def batch_enrich( ) ) - # Bulk update in a single query - if to_update: - stmt = ( - update(AlertEnrichment) - .where(AlertEnrichment.id.in_(to_update)) - .values(enrichments=enrichments) - ) - session.execute(stmt) - # Bulk insert new enrichments if to_create: session.add_all(to_create) From f8b27b8e616e4388e144ea9a5da72b8f739ac9da Mon Sep 17 00:00:00 2001 From: Bertrand Caplet Date: Mon, 18 Aug 2025 20:22:24 -0400 Subject: [PATCH 2/3] version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fadf6a303a..b91d2f24bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keep" -version = "0.47.0" +version = "0.47.1" description = "Alerting. for developers, by developers." authors = ["Keep Alerting LTD"] packages = [{include = "keep"}] From 5ad264de52a3d15174e7d231fdbb780e79c34759 Mon Sep 17 00:00:00 2001 From: Bertrand Caplet Date: Wed, 20 Aug 2025 09:27:31 -0400 Subject: [PATCH 3/3] 0.47.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b91d2f24bd..8a2c40bb2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keep" -version = "0.47.1" +version = "0.47.2" description = "Alerting. for developers, by developers." authors = ["Keep Alerting LTD"] packages = [{include = "keep"}]