Bulk edit overwrites Project changes made while waiting for a lock
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start by tracing the Projects bulk edit flow and ScriptProject.save(), especially where selected objects are loaded and locks are acquired. The report gives a reproducible PostgreSQL advisory lock sequence and confirms the same lost update for both name and comments. Done when bulk edits preserve concurrent changes to fields they do not modify and the reported reproduction no longer loses either update.
Written by the indexing model from the issue text.
Description
Plugin Version
v0.0.1
NetBox Version
v4.7.4
Python Version
3.12
Steps to Reproduce
- Create two Script Projects named "Alpha Devices" and "Bravo Devices", leaving their comments empty.
- In
manage.py nbshell, hold Alpha's Project lock. Keep the shell open:from django.db import connection from netbox_scripts.models import ScriptProject from netbox_scripts.storage.locks import advisory_key project = ScriptProject.objects.get(name='Alpha Devices') key = advisory_key(project.storage_key) cursor = connection.cursor() cursor.execute('SELECT pg_advisory_lock(%s, %s)', key) - Select both Projects in the Projects list and apply a bulk edit that sets their description to "bulk". The request waits for Alpha's lock.
- While it waits, rename Bravo through
PATCH /api/plugins/netbox-scripts/projects/<Bravo's id>/with{"name": "Bravo Devices Renamed"}. Confirm that the PATCH succeeds. - Release Alpha's lock in the shell:
cursor.execute('SELECT pg_advisory_unlock(%s, %s)', key) cursor.close()
Expected Behavior
Both descriptions become "bulk", and Bravo keeps its new name, "Bravo Devices Renamed". Fields not changed by the bulk edit retain updates committed while it was waiting.
Observed Behavior
The bulk edit succeeds, but Bravo's name returns to "Bravo Devices".
The change log records the rename, followed by the bulk edit with "Bravo Devices" in both its before and after data. The overwrite therefore does not appear as a name change in that entry.
Repeating the test with {"comments": "Edited during the wait"} in step 4 also loses the concurrent update, restoring the previous empty comments.
The bulk edit loads the selected Projects before ScriptProject.save() acquires their locks. After waiting, it saves those previously loaded instances, including fields the bulk edit did not change.
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 11h 41m
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from netbox-community/netbox-scripts
-
app: scripts Bucket: Improve status: backlog type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
netbox-community/netbox-scripts#80 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
netbox-community/netbox-scripts#76 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: medium status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
netbox-community/netbox-scripts#114 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
netbox-community/netbox-scripts#111 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
netbox-community/netbox-scripts#100 ·
Maintainers usually reply within 1 day
All issues in netbox-community/netbox-scripts
Similar issues
-
documentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MarketSquare/robotframework-browser#5479 ·
Maintainers usually reply within 1 day
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
endoflife-date/endoflife.date#11561 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OCA/l10n-brazil#5602 ·
Maintainers usually reply within 1 day
-
documentation review-2.0.0
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dkuenzel/meshcore-home-gateway#106 ·
Maintainers usually reply within 1 day