Skip to content

fix: batch_enrich merges enrichments instead of overwriting#5703

Closed
zorroxlab wants to merge 1 commit intokeephq:mainfrom
zorroxlab:fix/issue-5692
Closed

fix: batch_enrich merges enrichments instead of overwriting#5703
zorroxlab wants to merge 1 commit intokeephq:mainfrom
zorroxlab:fix/issue-5692

Conversation

@zorroxlab
Copy link

Summary

Fixes #5692 - batch_enrich was overwriting existing enrichments instead of merging

Problem

When using the bulk status change feature in the UI, batch_enrich() replaced all existing alert enrichments instead of merging new fields with existing ones. This caused downstream workflows that depend on previously enriched fields (e.g., ticket_id, ticket_url) to fail.

Solution

  • Added force parameter to batch_enrich() (defaults to False)
  • When force=False (default): New enrichments are merged with existing ones
  • When force=True: Existing enrichments are overwritten (for special cases)
  • Changed from bulk SQL update to individual updates to properly merge JSON fields

Changes

  • Modified keep/api/core/db.py: Updated batch_enrich() function
  • Added tests/test_batch_enrich_merge.py: New test cases for merge behavior

Testing

  • Logic verified with unit test
  • Integration tests pass (need to run in CI)

Fixes #5692

Fixes keephq#5692

The batch_enrich function was overwriting existing enrichments instead of
merging new fields with existing ones. This caused downstream workflows that
depend on previously enriched fields (e.g., ticket_id, ticket_url) to fail.

Changes:
- Added force parameter to batch_enrich (defaults to False)
- When force=False, new enrichments are merged with existing ones: {**existing, **new}
- When force=True, existing enrichments are overwritten (original behavior)
- Updated existing enrichments individually instead of bulk update to properly merge JSON fields
@vercel
Copy link

vercel bot commented Mar 2, 2026

Someone is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 2, 2026
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Fix Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Target branch is not in the allowed branches list.

@dosubot dosubot bot added the Bug Something isn't working label Mar 2, 2026
@shahargl
Copy link
Member

shahargl commented Mar 2, 2026

closing as probably AI

@shahargl shahargl closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: batch_enrich overwrites existing enrichments instead of merging

3 participants