Skip to content

Fixes #342: Error on update form if object has been deleted in main - #348

Merged
jnovinger merged 7 commits into
mainfrom
342-diff-main-2
Nov 7, 2025
Merged

jnovinger merged 7 commits into
mainfrom
342-diff-main-2

Conversation

@arthanson

@arthanson arthanson commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

Fixes: #342

Adds a warning if you try to modify an object that has been deleted in main. It is possible to make a fix to create the changelog without referring to main, however this will still result in an un-mergeable branch because of the way the merge plays back the changelogs in order, so a user message and preventing the save was decided as the better course of operation.

For delete - the post_save signal can come in before the pre_delete so put the check in both places.

This covers the update/delete of items that originally existed in main and were deleted in main but still exist in the branch. Also checks are made if the object was only created in the branch (so it doesn't exist in main as it never existed in main).

Monosnap Image 2025-10-28 15-07-32

@arthanson arthanson changed the title DRAFT: #342 Error on form if update and object that has been deleted in main #342 Error on form if update and object that has been deleted in main Oct 29, 2025
@arthanson
arthanson marked this pull request as ready for review October 29, 2025 17:10
@arthanson
arthanson requested a review from a team October 29, 2025 17:11
@jnovinger
jnovinger requested review from jnovinger and removed request for a team November 3, 2025 19:53
Comment thread netbox_branching/signal_receivers.py Outdated
Comment thread netbox_branching/signal_receivers.py Outdated
@jnovinger jnovinger changed the title #342 Error on form if update and object that has been deleted in main Fixes #342: Error on update form if object has been deleted in main Nov 3, 2025
@arthanson
arthanson requested a review from jnovinger November 4, 2025 21:25
Comment thread netbox_branching/signal_receivers.py
Comment thread netbox_branching/signal_receivers.py Outdated
Comment thread netbox_branching/signal_receivers.py Outdated
@arthanson

Copy link
Copy Markdown
Contributor Author

@jnovinger good catches, fixed.

@arthanson
arthanson requested a review from jnovinger November 6, 2025 17:11
@arthanson
arthanson marked this pull request as draft November 6, 2025 17:44
@arthanson

Copy link
Copy Markdown
Contributor Author

@jnovinger There was a bug case where if you created the object in the branch it was still complaining that it wasn't existing in main. I refactored the code to a common function as the testing was more complicated.

@arthanson
arthanson marked this pull request as ready for review November 6, 2025 18:54
@jnovinger
jnovinger merged commit 1c73316 into main Nov 7, 2025
12 checks passed
@jeremystretch
jeremystretch deleted the 342-diff-main-2 branch January 7, 2026 18:25
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.

Display warning if object has been deleted in main branch

2 participants