Skip to content

fix(revisions): publish a delta for a collected model instead of raising - #16

Open
ahinoamp wants to merge 1 commit into
Kitware:mainfrom
ahinoamp:fix/push-delta-collected-model
Open

ahinoamp wants to merge 1 commit into
Kitware:mainfrom
ahinoamp:fix/push-delta-collected-model

Conversation

@ahinoamp

Copy link
Copy Markdown
Contributor

Problem

RevisionsMixin.push_delta dereferences find_instance(msg["id"]) unconditionally:

key = self._track_revisions(self.find_instance(msg["id"]))

The instance registry holds weak references, so a delta flushed after its model was collected resolves to None. The whole flush then dies with AttributeError: 'NoneType' object has no attribute '_id'.

Change

When the instance is gone, the delta is published without a revision. get_state already answers {"id": ..., "state": None} for such an id, so what to do about a dropped instance stays with the client.

Test

test_a_delta_for_a_collected_model_is_published_without_a_revision runs on both protocol versions. It fails on the current code (2 failed) and passes with the change (22 passed in tests/test_protocol_revisions.py).

🤖 Generated with Claude Code

push_delta looked up the instance and dereferenced it unconditionally.
The registry holds weak references, so a delta flushed after its model
was collected resolved to None and the flush raised AttributeError.
Publish it without a revision; get_state already answers
{"id": ..., "state": None} for such an id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alesgenova

Copy link
Copy Markdown
Member

can you share more information about what issue prompted you to implement this fix?
the only pathway I can find is that if we create a deepcopy of a model instance it gets the same id as the original.
If the original instance gets later collected, we end with a possible crash.
Also having one id pointing to two instances is clearly a problem on its own.
Anyway, can you confirm whether the issue stemmed from copying a model instance? If so, the real fix would be to implement proper copying

This branch has not been deployed

No deployments
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.

2 participants