Skip to content

fix(providers): preserve tool-provided fingerprint when dedup rule uses only the fingerprint field - #6626

Open
ajuijas wants to merge 2 commits into
keephq:mainfrom
ajuijas:fix/2312-fingerprint-bypass
Open

fix(providers): preserve tool-provided fingerprint when dedup rule uses only the fingerprint field#6626
ajuijas wants to merge 2 commits into
keephq:mainfrom
ajuijas:fix/2312-fingerprint-bypass

Conversation

@ajuijas

@ajuijas ajuijas commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

When a deduplication rule's fingerprint_fields is exactly ["fingerprint"], BaseProvider.get_alert_fingerprint now returns the alert's existing fingerprint verbatim instead of SHA-256-hashing it. Every other fingerprint_fields combination 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 rewrites alert.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 AlertDto guarantees a fingerprint is always set); the bypass applies only when the rule's sole fingerprint field is fingerprint itself.

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:

4 passed in 0.04s

🤖 Generated with Claude Code

…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>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. Bug Something isn't working labels Jul 10, 2026
@CLAassistant

CLAassistant commented Jul 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[➕ Feature]: allow "bypassing" fingerprints (e.g. grafana, prometheus) without sha256 to allow alignment between tools

2 participants