You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I found some incorrect behaviour of changelogs.
Environment
Python version: 3.6.8
Nautobot version: v1.0.1
Steps to Reproduce
Let's create an object in Nautobot - IP address, e.g. 127.0.0.1 that has a tag attached + some attributes e.g name, description (I was testing this also on a VLAN and presumably it relates to all object types with tags.)
Modify this object's attribute(s) - let's say description field (do not modify the tags!) via API request.
This creates a changelog showing that not only the description was changed but also that tags were removed by this person in this update.(first changelog incorrect information) Just fyi: this happens either via pynautobot or simple patch request (e.g. via Postman). I'm adding this piece of information here because it is quite relevant information for a "workaround" that I found.
Changelog seems fine at a first sight. Only description is changed as it treats somehow the object as being without tags! Although those are still visible in GUI
(Well, anyway, omitting the changelog information the actual state of the object is as expected - description is modified and the tags are as they were)
Modify the object's description via Nautobot GUI. As soon as someone modifies the same object via Nautobot GUI - even an "empty update" or simply just change some field only then a new changelog record is created and it will show that this update actually added 'new tags' (those that were and still are attached to the object and those that appeared to be removed in the second step)(second changelog incorrect information)
Expected Behavior
The changelog records for each action should show only the changes that were actually made by that user within that particular update.
Observed Behavior
The changelog produces incorrect logs about user actions (removing and adding tags to the object) that a user simply didn't do. (And that also did not happen "under the hood" due to same inner chain of relationships because the object actually keeps the tag(s) unchanged).
Other findings / Possible "workaround"
Because I needed to find a way if it is possible to keep data consistent as well as logs (which are very important for keeping an eye on a history of changes) I found out that Nautobot treats differently Patch request's attributes which are passed.
Normally and for all the data (except tags) only those data present in the patch request are updated and others are untouched (expected behaviour). Nevertheless, for tags - empty tags mean "removing" them (well, only in changelog though). In order to make tags look untouched also in the logs, they have to be sent also in the path request (e.g. their IDs). Then the tags will remain in the object and the log will not look like that the tags were updated.
Well, and this approach is possible only for direct API request but not for pyautobot. Because as I found out, pynautobot library does some pre-checks and the tags which seems to be already presented in the object are removed from a request before the patch request is sent... Hence it is not possible to use pynautobot and successfully update nautobot object keeping information about tags true in logs. It is possible though to do so at least with this workaround while using requests library or Postman etc.
The text was updated successfully, but these errors were encountered:
Yes, this seems very alike or actually identical issue.
Don't know how much does the nautobot code base differ in this case but I assume that this one line modification could fix it also for Nautobot? ;-)
Hi, I found some incorrect behaviour of changelogs.
Environment
Steps to Reproduce
Let's create an object in Nautobot - IP address, e.g. 127.0.0.1 that has a tag attached + some attributes e.g name, description (I was testing this also on a VLAN and presumably it relates to all object types with tags.)
Modify this object's attribute(s) - let's say description field (do not modify the tags!) via API request.
This creates a changelog showing that not only the description was changed but also that tags were removed by this person in this update. (first changelog incorrect information)
Just fyi: this happens either via pynautobot or simple patch request (e.g. via Postman). I'm adding this piece of information here because it is quite relevant information for a "workaround" that I found.
Changelog seems fine at a first sight. Only description is changed as it treats somehow the object as being without tags! Although those are still visible in GUI
(Well, anyway, omitting the changelog information the actual state of the object is as expected - description is modified and the tags are as they were)
As soon as someone modifies the same object via Nautobot GUI - even an "empty update" or simply just change some field only then a new changelog record is created and it will show that this update actually added 'new tags' (those that were and still are attached to the object and those that appeared to be removed in the second step) (second changelog incorrect information)
Expected Behavior
The changelog records for each action should show only the changes that were actually made by that user within that particular update.
Observed Behavior
The changelog produces incorrect logs about user actions (removing and adding tags to the object) that a user simply didn't do. (And that also did not happen "under the hood" due to same inner chain of relationships because the object actually keeps the tag(s) unchanged).
Other findings / Possible "workaround"
Because I needed to find a way if it is possible to keep data consistent as well as logs (which are very important for keeping an eye on a history of changes) I found out that Nautobot treats differently Patch request's attributes which are passed.
Normally and for all the data (except tags) only those data present in the patch request are updated and others are untouched (expected behaviour). Nevertheless, for tags - empty tags mean "removing" them (well, only in changelog though). In order to make tags look untouched also in the logs, they have to be sent also in the path request (e.g. their IDs). Then the tags will remain in the object and the log will not look like that the tags were updated.
Well, and this approach is possible only for direct API request but not for pyautobot. Because as I found out, pynautobot library does some pre-checks and the tags which seems to be already presented in the object are removed from a request before the patch request is sent... Hence it is not possible to use pynautobot and successfully update nautobot object keeping information about tags true in logs. It is possible though to do so at least with this workaround while using requests library or Postman etc.
The text was updated successfully, but these errors were encountered: