fix(providers): preserve tool-provided fingerprint when dedup rule uses only the fingerprint field - #6626
Open
ajuijas wants to merge 2 commits into
Open
fix(providers): preserve tool-provided fingerprint when dedup rule uses only the fingerprint field#6626ajuijas wants to merge 2 commits into
ajuijas wants to merge 2 commits into
Conversation
…es only the fingerprint field When a custom deduplication rule's fingerprint_fields is exactly ["fingerprint"], the alert already carries a fingerprint from the monitoring tool (e.g. Grafana/Prometheus, whose providers declare FINGERPRINT_FIELDS = ["fingerprint"]). Hashing it through SHA-256 in BaseProvider.get_alert_fingerprint breaks alignment between Keep's fingerprint and the tool's. Return it verbatim instead; all other fingerprint_fields combinations keep the existing hashing behavior. Fixes keephq#2312 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a deduplication rule's
fingerprint_fieldsis exactly["fingerprint"],BaseProvider.get_alert_fingerprintnow returns the alert's existing fingerprint verbatim instead of SHA-256-hashing it. Every otherfingerprint_fieldscombination keeps the current hashing behavior.Why
Grafana and Prometheus send their own fingerprint, and both providers declare
FINGERPRINT_FIELDS = ["fingerprint"]. As soon as a custom dedup rule with those fields is applied (e.g. created automatically when the default rule is edited in the UI), Keep rewritesalert.fingerprint = sha256(tool_fingerprint), breaking alignment between Keep's fingerprint and the monitoring tool's.Hashing a fingerprint that the tool already provides adds no dedup value — it's already a stable unique key — and only loses the correlation with the source tool.
Unlike the earlier attempt in #4765, this does not return the existing fingerprint unconditionally (which would disable all custom dedup rules, since
AlertDtoguarantees a fingerprint is always set); the bypass applies only when the rule's sole fingerprint field isfingerprintitself.Fixes #2312
How it was tested
Added a regression test in
tests/test_get_alerts_custom_dedup.py(test_custom_dedup_on_fingerprint_field_preserves_tool_fingerprint); the full file passes locally:🤖 Generated with Claude Code