Skip to content

Erroneous custom scripts get registered in database, but there is no visible option to remove them #21737

@mburggraf

Description

@mburggraf

NetBox Edition

NetBox Community

NetBox Version

v4.5.5

Python Version

3.12

Steps to Reproduce

  1. Create a faulty custom script; for example:
from extras.script import Script
# note the typo in the package name above
class TestScript(Script):
    pass
  1. Go to Customization > Scripts and Click on Add, and upload the faulty script. → the script won't appear in the list of existing scripts.
  2. Try to upload again (Usually you would fix any bugs, but for this case it's not necessary) and see the error.

Expected Behavior

A defective script shouldn't be registered in the database, or if it get's registered, there should be a way to remove or overwrite it.
Since there is no visible result on the first upload try, the user doesn't even see that something is wrong with his script.

Observed Behavior

A server error is raised:

<class 'django.db.utils.IntegrityError'>

duplicate key value violates unique constraint "core_managedfile_unique_root_path"
DETAIL:  Key (file_root, file_path)=(scripts, test.py) already exists.

Python-Version: 3.12.3
NetBox-Version: 4.5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    netboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationtype: bugA confirmed report of unexpected behavior in the application

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions