Skip to content

[FIX] alerts: pristine-snapshot comparison + Celery session/pool reset after fork#1096

Open
lykosi wants to merge 1 commit into
dfir-iris:developfrom
lykosi:fix/alerts-pristine-comparison-celery-fork-safety
Open

[FIX] alerts: pristine-snapshot comparison + Celery session/pool reset after fork#1096
lykosi wants to merge 1 commit into
dfir-iris:developfrom
lykosi:fix/alerts-pristine-comparison-celery-fork-safety

Conversation

@lykosi

@lykosi lykosi commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Two bug fixes on alert updates.

alerts.py

The alert object was already reflecting new values by the time the old/new comparison ran. This produced no-op history entries ("alert_status_id" from "4" to "4") and silently skipped /alert/status-update and /alert/resolution-update webhooks.

  • Fix: take a copy.copy(alert) snapshot before any mutations and use it as the comparison baseline.

module_handler.py

Celery prefork workers inherit the parent's DB session and open connections, causing shared connections across processes. This results in interleaved queries and stale transaction state, which directly caused multiple webhook hooks to fail silently.

  • Fix: call db.session.remove() + db.engine.dispose() at task entry to discard the inherited state.

Test plan

  • Updated an alert changing status and resolution -> activity history shows correct before/after values, all three webhooks fire

BEFORE
BEFORE_COMPARISON
AFTER
AFTER_COMPARISON

  • Setting a field to its existing value no longer creates a history entry

BEFORE
BEFORE_CHANGES
AFTER
AFTER_CHANGES

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • api_*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66e02632-cbf0-487e-8a8e-f9cd854347ed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant