Skip to content

fix: compare full event paths when skipping duplicate notices - #2684

Open
Ali-932 wants to merge 2 commits into
canonical:mainfrom
Ali-932:fix-dedup-path-key
Open

fix: compare full event paths when skipping duplicate notices#2684
Ali-932 wants to merge 2 commits into
canonical:mainfrom
Ali-932:fix-dedup-path-key

Conversation

@Ali-932

@Ali-932 Ali-932 commented Aug 7, 2026

Copy link
Copy Markdown

The dedup check in Framework._event_is_in_storage() compared notice paths
truncated at the first [, which erases the emitter's key and the event kind
for events emitted by keyed objects. While one such event sat deferred,
distinct events (a different instance, or a different event kind) with equal
snapshots and the same observer method were skipped as duplicates and lost.

This changes the comparison to strip only the trailing [id], matching the
intent described in the comment above it.

Added a regression test with two keyed emitters and two event kinds sharing
one observer: it fails before the change (only 1 of 3 events delivered,
assert 1 == 3) and passes after. The full test/test_framework.py suite
passes (100/100).

Fixes #2683

@benhoyt benhoyt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rationale and logic makes sense to me, thanks for this.

@benhoyt
benhoyt requested a review from tromai August 10, 2026 00:06

@tromai tromai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix.

I really appreciate the detailed issue write up.

Comment thread test/test_framework.py
Comment on lines +580 to +583
self.seen.append(event.handle.path)
if self.defer_next:
self.defer_next -= 1
event.defer()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the intention of this logic is to defer only the first event, since we set obs.defer_next = 1 before the first emit and never touch it again. If that's correct, maybe something like this would be easier to follow:

first = len(self.seen) == 0
self.seen.append(event.handle.path)
if first:
    self.defer()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, i have updated the tests.

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.

Deferred event dedup can silently drop different events

4 participants