A cancelled run can end as Errored after committing its changes

Open
#3 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@pheus is already working on this.

Since Oct 23, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by tracing the cutover cancellation path, scheduler queueing, and the existing cancellation and completion notification handling for Custom Script Jobs. Reproduce the timing race with the listed NetBox and plugin versions, then verify that a successfully committed run ends as Completed without a duplicate notification error and that the owner receives the appropriate notification.

Written by the indexing model from the issue text.

Description

app: scripts severity: medium status: backlog type: bug
Plugin Version

v0.0.1

NetBox Version

v4.7.1

Python Version

3.12

Steps to Reproduce
  1. With notifications at their default setting, schedule a built-in Custom Script under Customization > Scripts to run a few minutes ahead.
  2. Under Scripts > Migration, run inventory and Stage Projects, then wait for valid revisions.
  3. Select Enter cutover so cancellation overlaps the scheduler queueing the due run. This timing race allows the cancelled run to execute.
Expected Behavior

If the Script has executed successfully and committed its changes, its Job ends as Completed. An existing cancellation notification should not turn the completed run into an error.

Observed Behavior

The Script commits its changes, but its Job ends as Errored with:

duplicate key value violates unique constraint "extras_notification_unique_per_object_and_user"

Cutover has already notified the owner about cancellation. Creating a completion notification for the same Job and user violates the uniqueness constraint, leaving the owner with only the cancellation notice.

Dominant language
Python
Stars
8
Forks
0
Avg merge
9h 56m
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from netbox-community/netbox-scripts

All issues in netbox-community/netbox-scripts

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.