keep icon indicating copy to clipboard operation
keep copied to clipboard

[🐛 Bug]: Route get alerts/{fingerprint} doesn't work as expected, can't fetch an alert that isn't in the last 1000 alerts

Open DolevNe opened this issue 4 months ago • 1 comments

Describe the bug the function that gets the alert by fingerprint uses a function that fetches the last 1000 alerts (get_last_alerts)

To Reproduce try to get an alert by fingerprint that isn't from the last 1000 alerts

Expected behavior the route should use the function get_last_alerts_by_fingerprints Screenshots

Image fix: Image

Additional context I think the same behavior is repeated when trying to query a preset of "old" alerts

DolevNe avatar Aug 14 '25 10:08 DolevNe

You're right—the current implementation of the get alerts/{fingerprint} route only searches the last 1000 alerts because it uses get_last_alerts, which imposes this limit. This means you can't fetch alerts by fingerprint if they're older than the most recent 1000 alerts. The correct approach is to use get_last_alerts_by_fingerprints, which queries the most recent alert for each fingerprint without the 1000-alert limit and is already used in other parts of the codebase for batch enrichment and similar operations. Updating the route to use this function will resolve the issue and allow you to fetch alerts by fingerprint regardless of their recency.

The same limitation likely affects any other route or feature that relies on get_last_alerts, including querying presets of old alerts, so those should be reviewed for similar fixes as well.
See code reference

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Aug 14 '25 11:08 dosubot[bot]