Skip to content

Conversation

@Kiryous
Copy link
Contributor

@Kiryous Kiryous commented Jul 3, 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

  • Allow UUID fingerprint in enrichments_bl.enrich_entity to save uuid in db-specific way.
  • Removed migration since for alerts fingerprints always stored as string and migration will can cause incinsistency. 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 threading.lock() in workflowmanager.get_instance() to ensure we always will have an instance with scheduler

@vercel
Copy link

vercel bot commented Jul 3, 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 4, 2025 11:17am

@Kiryous Kiryous marked this pull request as ready for review July 3, 2025 15:22
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug Something isn't working labels Jul 3, 2025
cursor[bot]

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 30.74%. Comparing base (0026346) to head (d347f64).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
keep/workflowmanager/workflowmanager.py 25.00% 6 Missing ⚠️
keep/api/bl/enrichments_bl.py 0.00% 2 Missing ⚠️
keep/contextmanager/contextmanager.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5142       +/-   ##
===========================================
- Coverage   46.18%   30.74%   -15.44%     
===========================================
  Files         173      101       -72     
  Lines       17970    11492     -6478     
===========================================
- Hits         8299     3533     -4766     
+ Misses       9671     7959     -1712     

☔ 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 requested a review from shahargl July 3, 2025 19:50
@Kiryous Kiryous requested a review from VladimirFilonov July 4, 2025 07:25
@Kiryous
Copy link
Contributor Author

Kiryous commented Jul 4, 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

Added migration and logic to handle UUID formatting inconsistencies in alert fingerprints across different database dialects (MySQL, SQLite, PostgreSQL).

  • Added migration 2025-07-01-12-19_alertenrichment_uuid_dashes.py but lacks PostgreSQL implementation and proper downgrade function
  • Modified enrichments_bl.py to handle UUIDs consistently using SQLAlchemy's UUIDType for dialect-specific formatting
  • Added thread-safety in workflowmanager.get_instance() with proper double-checked locking pattern
  • Extended test coverage for incident enrichment with UUID handling and multi-database support

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

VladimirFilonov
VladimirFilonov previously approved these changes Jul 4, 2025
Copy link
Contributor

@VladimirFilonov VladimirFilonov left a comment

Choose a reason for hiding this comment

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

Nice!

…string and migration will can cause incinsistency
cursor[bot]

This comment was marked as outdated.

@cursor
Copy link

cursor bot commented Jul 4, 2025

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_1815e490-4824-4126-9816-85dbb1f7c66c).

cursor[bot]

This comment was marked as outdated.

@Kiryous
Copy link
Contributor Author

Kiryous commented Jul 4, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ BugBot reviewed your changes and found no bugs!


Was this report helpful? Give feedback by reacting with 👍 or 👎

@Kiryous Kiryous merged commit 499ab7a into main Jul 4, 2025
22 checks passed
@Kiryous Kiryous deleted the fix/5097-wf-incident-enrichment-3 branch July 4, 2025 12:56
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: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