Repository navigation
move log_sync_status calls until after object creation. - #379
Open
Kircheneer wants to merge 3 commits into
Open
Kircheneer wants to merge 3 commits into
Kircheneer wants to merge 3 commits into
Conversation
Kircheneer
requested review from
glennmatthews,
jdrew82 and
michalis1
as code owners
November 30, 2026 10:00
DiffSync currently logs creation before adding the new object to its target store, preventing log consumers such as Nautobot SSoT from accessing newly created objects. Logging after insertion makes the object available for linking creation logs to the corresponding record. Here is a little call graph to illustrate this: sync_diff_element() ├─ sync_model() │ └─ Model.create() → new model │ └─ creation log ← previously here ├─ target.add(new_model) ├─ creation log ← now here │ └─ SSoT lookup_object() │ └─ target.get(type, unique_id) ← object is now available └─ synchronize children
Kircheneer
force-pushed
the
move-sync-status-logging
branch
from
November 30, 2026 10:05
1df52ae to
0d0d0c2
Compare
Comment on lines
+114
to
+115
| assert events[0]["status"] == "error" | ||
| assert events[0]["event"] == "backend rejected creation" |
Collaborator
There was a problem hiding this comment.
It's not obvious to me why some of the events assertions are implemented inside def observe(event) while others are implemented separately, as here. What was the decision process?
Contributor
Author
There was a problem hiding this comment.
My apologies for the renewed slop. I have reverted to what I would have tested if I had turned on my brain, which is just the new behaviour. I feel like what I now have is useful.
glennmatthews
previously approved these changes
Nov 30, 2026
glennmatthews
left a comment
Collaborator
There was a problem hiding this comment.
The fix seems reasonable to me, though it feels inelegant to move from one central call site for log_sync_status to two conditional ones, I think I can understand why it was needed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: I used AI to help research and make this change.
DiffSync currently logs creation before adding the new object to its target store, preventing log consumers such as Nautobot SSoT from accessing newly created objects. Logging after insertion makes the object available for linking creation logs to the corresponding record.
Here is a little call graph to illustrate this:
sync_diff_element()
├─ sync_model()
│ └─ Model.create() → new model
│ └─ creation log ← previously here
├─ target.add(new_model)
├─ creation log ← now here
│ └─ SSoT lookup_object()
│ └─ target.get(type, unique_id) ← object is now available
└─ synchronize children
The goal is to eventually make it possible to let
lookup_objectin SSoT always populate thesynced_object_idin theSyncLogEntry, even at creation time, and without workarounds/performance issues.