Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange output in diff visualization when applying a tag #179

Open
LucaNicosia opened this issue Nov 19, 2024 · 1 comment
Open

Strange output in diff visualization when applying a tag #179

LucaNicosia opened this issue Nov 19, 2024 · 1 comment
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@LucaNicosia
Copy link

Plugin Version

0.5.2

NetBox Version

4.1.6

Python Version

3.10.2

Steps to Reproduce

  1. Create a branch
  2. Checkout into the branch
  3. Create an object (f.e. a site) w/out a tag
  4. Go into the diff tab of the branch page
  5. The object will be created (as expected)
  6. Edit the object created at point 3 and add a tag
  7. Go back into the diff tab of the branch page
  8. The object column is now None (FIRST PROBLEM)
  9. Create a new object and assign it a tag this time
  10. Go into the Changes ahead tab of the branch page
  11. The creation of an object resulted into 2 different operations: object creation & object update with the tag (SECOND PROBLEM)
  12. Due to problem at point 8, the object column in the diff page is None also for this record

image

Expected Behavior

  1. Always see the object in the diff page
  2. When I create a new record with a tag, I expect one single action

Observed Behavior

I've attached to this message reproducing all the steps above

show-netbox-tag-problems.mp4
@LucaNicosia LucaNicosia added the type: bug A confirmed report of unexpected behavior in the application label Nov 19, 2024
@cruse1977
Copy link
Member

cruse1977 commented Jan 28, 2025

On point 8 - this occurs on adding a tag and the object_repr in the ChangeDiff objects is set to None.

Currently the ChangeDiff save method always updates the object_repr:

    def save(self, *args, **kwargs):
        self._update_conflicts()
        super().save(*args, **kwargs)

Wrapping this in a conditional (as per below) prevents the object_repr from being updated thus shown the correct object rather than None - however, this may be better resolved by a change in the signal receivers.

    def save(self, *args, **kwargs):
        self._update_conflicts()
        if self.object:
            self.object_repr = str(self.object)

        super().save(*args, **kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants