Skip to content

Conversation

@lucaspgz
Copy link

…, and also fix the restore/dismiss bug from the ui

Closes #5047

📑 Description

This pull request addresses two main points:

  • Fixes the bug related to cleaning the dismissed, dismissUntil, and disposable_* fields of an alert after dismissUntil expiration, and also restores the alert's previous status (sent in batch_enrich now) when dismissUntil expires.
  • Fixes the bug in the UI where selecting two alerts in the feed, even if both are dismissed, triggers the dismiss pop-up, instead of the restore one in that case.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

It has been tested both with dedicated tests and via direct alert sending through API, dismissing them with a workflow, and also via the UI tool. It works correctly for single or multiple alerts, as needed.

…, and also fix the restore/dismiss bug from the ui
@vercel
Copy link

vercel bot commented Jul 15, 2025

@lucaspgz is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Jul 15, 2025

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Bug Something isn't working UI User interface related issues labels Jul 15, 2025
@lucaspgz lucaspgz changed the title Fixed dismissed bug fix: dismissed bug Jul 15, 2025
@cursor
Copy link

cursor bot commented Jul 15, 2025

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_bf29c8c0-631a-4f95-908b-558ae99a67cb).

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 16, 2025
cursor[bot]

This comment was marked as outdated.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 16, 2025
cursor[bot]

This comment was marked as outdated.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 16, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@lucaspgz lucaspgz closed this Jul 16, 2025
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.

Bug: Function Calls Pass Incorrect Data Type

The batch_enrich function and the enrich_entity method were updated to expect a list[dict] for their enrichment parameter (now named enrichments_list). However, at two call sites, a single dict is still being passed instead of a list containing the dictionary. This occurs in restore_previous_status when calling batch_enrich with updated_enrichments, and in assign_alert when calling enrich_entity with enrichments. The passed dictionaries should be wrapped in a list (e.g., [dict_variable]).

keep/api/bl/enrichments_bl.py#L954-L963

# Save the updated enrichment data in the database and Elasticsearch
batch_enrich(
tenant_id,
[fingerprint],
updated_enrichments,
action_type=ActionType.DISPOSE_ENRICHED_ALERT,
action_callee='system',
action_description='Restore previous status after dismiss',
session=session,
)

keep/api/routes/alerts.py#L438-L439

fingerprint=fingerprint,
enrichments_list=enrichments,

keep/api/routes/alerts.py#L911-L912

fingerprints=fingerprints,
enrichments_list=enrichments,

keep/api/routes/alerts.py#L935-L936

fingerprints=formatted_alert_ids,
enrichments_list=enrichments,

Fix in CursorFix in Web


Bug: Test Ineffectiveness: Missing Disposable Fields

The tests test_dispose_dismiss_in_future_keeps_disposables and test_dispose_dismiss_no_dismissUntil are ineffective. They are intended to verify the preservation of disposable_* enrichments but do not add any disposable_* fields to the alert, rendering their assertions for these keys meaningless.

tests/test_enrichments.py#L1243-L1248

keep/tests/test_enrichments.py

Lines 1243 to 1248 in c4759ed

# Verify disposable_* keys still exist (not removed)
enrichment = get_enrichments(mock_session, mock_alert_dto.fingerprint)
for key in enrichment:
if key.startswith("disposable_"):
# At least one disposable key should still be present
assert key in enrichment

tests/test_enrichments.py#L1263-L1268

keep/tests/test_enrichments.py

Lines 1263 to 1268 in c4759ed

# Verify disposable_* keys still exist (nothing should be removed)
enrichment = get_enrichments(mock_session, mock_alert_dto.fingerprint)
# Tu código debe verificar que los "disposable_*" permanecen
for key in enrichment:
if key.startswith("disposable_"):
assert key in enrichment

Fix in CursorFix in Web


Bug: Method Parameter Mismatch Causes Error

The enrich_entity method is called with the parameter enrichments_list, but its signature was not updated and still expects enrichments, which will cause a TypeError.

keep/api/routes/alerts.py#L436-L442

enrichment_bl = EnrichmentsBl(tenant_id)
enrichment_bl.enrich_entity(
fingerprint=fingerprint,
enrichments_list=enrichments,
action_type=ActionType.ACKNOWLEDGE,
action_description=f"Alert assigned to {user_email}, status: {status}",
action_callee=user_email,

Fix in CursorFix in Web


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

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. UI User interface related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: CEL filters not returning alerts with dismissed: false after dismissedUntil expires

2 participants