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

'Cannot call get_descendants on unsaved Location instances' error when merging new location and child location #143

Closed
duckw opened this issue Sep 23, 2024 · 2 comments
Assignees
Labels
type: bug Something isn't working

Comments

@duckw
Copy link

duckw commented Sep 23, 2024

Plugin Version

0.5.0

NetBox Version

4.1.1

Python Version

3.12

Steps to Reproduce

  1. Add new branch
  2. Activate new branch
  3. Create new location to an existing site
  4. Click 'Add Child Location'
  5. Create the child location
  6. Merge the branch
  7. Check the merge job status

Expected Behavior

Merge to be successful.

Observed Behavior

Branch merge job shows the following:

{
"log": [
"Merging branch LOCTEST (branch_qv0723dh)",
"Found 2 changes to merge",
"Setting branch status to merging",
"Applying change DCIM | location TEST1 created by admin using default",
"Creating location <DeserializedObject: dcim.Location(pk=7875)>",
"Applying change DCIM | location TEST2 created by admin using default",
"Creating location <DeserializedObject: dcim.Location(pk=7876)>",
"Cannot call get_descendants on unsaved Location instances"
]
}

@duckw duckw added the type: bug Something isn't working label Sep 23, 2024
@jeremystretch jeremystretch self-assigned this Sep 23, 2024
@jeremystretch
Copy link
Contributor

The root issue here is that NetBox's Location model evaluates the instance's primary key when determining whether the object is being created or updated in the database. Normally this is fine, however because we're populating a record (from a branch) with a predetermined primary key, this incorrect triggers MPTT to query for child locations.

I've opened NetBox bug #17577 to address this upstream, for all affected models.

@jeremystretch
Copy link
Contributor

#17577 has been resolved and this issue should be fixed in NetBox v4.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants