Skip to content

fix: incident enrichment via workflow when using mysql #5098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 45 commits into from

Conversation

Kiryous
Copy link
Contributor

@Kiryous Kiryous commented Jun 25, 2025

Closes #5097

Problem

When enriching incident via workflow, python-side str(uuid) is called to get alert_fingerprint for alertenrichment entry.

https://github.com/keephq/keep/blob/v0.45.11/keep/providers/base/base_provider.py#L244-L245

Therefore, when we look up incident enrichments using cast(alert_fingerprint as char) no enrichments will be found, because python will convert uuid to string with dashes, while mysql will convert to string without dashes:

https://github.com/keephq/keep/blob/v0.45.11/keep/api/core/db.py#L3979-L3990

Summary

  • Added __convert_to_uuid_dialect_str in keep/api/core/db.py to introduce for proper UUID handling across different databases.
  • Added migration 2025-07-01-12-19_alertenrichment_uuid_dashes.py to standardize UUID formatting across database dialects by removing dashes.
  • Test-related changes:
    • Added safeguard in tests by setting KEEP_STORE_WORKFLOW_LOGS=false to prevent test failures due to db_session fixture table drops
    • Fixed scheduler initialization edge case in keep/workflowmanager/workflowmanager.py to ensure proper workflow manager restarts

Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
keep ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2025 10:51am

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 68.25397% with 20 lines in your changes missing coverage. Please review.

Project coverage is 46.85%. Comparing base (0026346) to head (c4eb66f).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
keep/api/core/db.py 43.75% 9 Missing ⚠️
keep/workflowmanager/workflowmanager.py 69.56% 7 Missing ⚠️
tests/conftest.py 66.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5098      +/-   ##
==========================================
+ Coverage   46.18%   46.85%   +0.67%     
==========================================
  Files         173      174       +1     
  Lines       17970    18090     +120     
==========================================
+ Hits         8299     8476     +177     
+ Misses       9671     9614      -57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Kiryous Kiryous marked this pull request as ready for review July 1, 2025 09:46
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug Something isn't working Incident labels Jul 1, 2025
@Kiryous
Copy link
Contributor Author

Kiryous commented Jul 1, 2025

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Comprehensive fix for incident enrichment visibility in MySQL deployments by addressing UUID format inconsistencies and workflow-related issues across different database dialects.

  • Added migration script 2025-07-01-12-19_alertenrichment_uuid_dashes.py to standardize UUID formatting across database dialects by removing dashes
  • Modified keep/api/core/db.py to introduce __convert_to_uuid_dialect_str for proper UUID handling across different databases
  • Added safeguard in tests by setting KEEP_STORE_WORKFLOW_LOGS=false to prevent test failures due to db_session fixture table drops
  • Fixed scheduler initialization edge case in keep/workflowmanager/workflowmanager.py to ensure proper workflow manager restarts

7 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile

Kiryous and others added 3 commits July 1, 2025 13:58
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: Kirill Chernakov <yakiryous@gmail.com>
Copy link
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

Comment on lines 58 to 61
if not self.scheduler:
self.logger.debug("Scheduler was stopped, reinitializing it")
self.scheduler = WorkflowScheduler(self)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, how is it possible that "self.started" is true and not self.scheduler? if its because of raise condition, than it means that right after you start it, the self.started will become false and stop won't work anymore

cursor[bot]

This comment was marked as outdated.

@Kiryous Kiryous marked this pull request as draft July 1, 2025 16:41
@Kiryous Kiryous closed this Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Incident size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Incident made enrichments via workflow aren't visible when using mysql
3 participants