Cannot add or remove scripts from Custom Scripts after updating to 3.5.0 #7973

Closed
opened 2025-12-29 20:30:39 +01:00 by adam · 6 comments
Owner

Originally created by @parkerschoenig on GitHub (May 1, 2023).

Originally assigned to: @arthanson on GitHub.

NetBox version

v.3.5.0

Python version

3.8

Steps to Reproduce

  1. Add any custom Python script into /opt/netbox/netbox/scripts
  2. Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up

OR

  1. Remove any existing script from /opt/netbox/netbox/scripts that was present before upgrading to v3.5.0
  2. Access Scripts tab on web UI, this will result in an error message on web UI.

Originally I thought this was due to a bug with the netbox-secrets plugin (not supported on 3.5.0 yet, hence why the Changelog doesn't work) so I have removed the netbox-secrets plugin and dropped the related tables from the psql DB according to the Remove a Plugin documentation and restarted NetBox, however the issue with the custom scripts.

Expected Behavior

New scripts should be present in the "Scripts" tab in NetBox, removed script should not be present / not error.

Observed Behavior

Server Error
There was a problem with your request. Please contact an administrator.

The complete exception is provided below:

<class 'FileNotFoundError'>

[Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/add_device_type_components.py'

Python version: 3.8.10
NetBox version: 3.5.0

Originally created by @parkerschoenig on GitHub (May 1, 2023). Originally assigned to: @arthanson on GitHub. ### NetBox version v.3.5.0 ### Python version 3.8 ### Steps to Reproduce 1. Add any custom Python script into /opt/netbox/netbox/scripts 2. Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up OR 1. Remove any existing script from /opt/netbox/netbox/scripts that was present before upgrading to v3.5.0 2. Access Scripts tab on web UI, this will result in an error message on web UI. ~~Originally I thought this was due to a bug with the netbox-secrets plugin (not supported on 3.5.0 yet, hence why the Changelog doesn't work) so I have removed the netbox-secrets plugin and dropped the related tables from the psql DB according to the Remove a Plugin documentation and restarted NetBox, however the issue with the custom scripts.~~ ### Expected Behavior New scripts should be present in the "Scripts" tab in NetBox, removed script should not be present / not error. ### Observed Behavior Server Error There was a problem with your request. Please contact an administrator. The complete exception is provided below: <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/add_device_type_components.py' Python version: 3.8.10 NetBox version: 3.5.0
adam added the type: bugstatus: accepted labels 2025-12-29 20:30:39 +01:00
adam closed this issue 2025-12-29 20:30:39 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 1, 2023):

It's not clear from your description exactly what steps you're taking. How are you adding the new script? What script are you removing? Please edit your post above to provide clear instructions so that someone else can attempt to replicate the behavior.

@jeremystretch commented on GitHub (May 1, 2023): It's not clear from your description exactly what steps you're taking. How are you adding the new script? What script are you removing? Please edit your post above to provide clear instructions so that someone else can attempt to replicate the behavior.
Author
Owner

@parkerschoenig commented on GitHub (May 1, 2023):

Apologies. I have tried to make the steps to reproduce more clear, basically I already had a custom script in /opt/netbox/netbox/scripts long before upgrading to 3.5.0 and I can see that script in the "scripts" tab in NetBox. If I try to add more scripts into /opt/netbox/netbox/scripts they do not show up in the "scripts" tab in NetBox. It only just shows that one script that was present before the upgrade.

But also, if I remove that script that existed in /opt/netbox/netbox/scripts before upgrading to 3.5.0 (meaning there is no custom scripts present in /opt/netbox/netbox/scripts at all) and I go to the "scripts" tab in NetBox, I get the following error:

<class 'FileNotFoundError'>

[Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/<script_name>.py'

Python version: 3.8.10
NetBox version: 3.5.0

@parkerschoenig commented on GitHub (May 1, 2023): Apologies. I have tried to make the steps to reproduce more clear, basically I already had a custom script in /opt/netbox/netbox/scripts long before upgrading to 3.5.0 and I can see that script in the "scripts" tab in NetBox. If I try to add more scripts into /opt/netbox/netbox/scripts they do not show up in the "scripts" tab in NetBox. It only just shows that one script that was present before the upgrade. But also, if I remove that script that existed in /opt/netbox/netbox/scripts before upgrading to 3.5.0 (meaning there is no custom scripts present in /opt/netbox/netbox/scripts at all) and I go to the "scripts" tab in NetBox, I get the following error: <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/opt/netbox/netbox/scripts/<script_name>.py' Python version: 3.8.10 NetBox version: 3.5.0
Author
Owner

@kkthxbye-code commented on GitHub (May 2, 2023):

I think the issue here is that scripts and reports work significantly different in 3.5.0 than before, and to be honest it's not really documented very well in the release notes.

There's now a concrete database representation of an "installed" script in the database, see: https://github.com/netbox-community/netbox/issues/12068

The reason your scripts were there after the upgrade, is that a migration runs, importing the scripts from the script folder. The new way of working with scripts consist of using the Add script button on the script page and either uploading the script directly, or using the new data sync feature. Deleting scripts is done by using the delete script button.

To be honest, I haven't had a lot of time myself to play around with the new script/report setup in 3.5.0, so another maintainer might be able to shine more light on the intended workflow.

@kkthxbye-code commented on GitHub (May 2, 2023): I think the issue here is that scripts and reports work significantly different in 3.5.0 than before, and to be honest it's not really documented very well in the release notes. There's now a concrete database representation of an "installed" script in the database, see: https://github.com/netbox-community/netbox/issues/12068 The reason your scripts were there after the upgrade, is that a migration runs, importing the scripts from the script folder. The new way of working with scripts consist of using the Add script button on the script page and either uploading the script directly, or using the new data sync feature. Deleting scripts is done by using the delete script button. To be honest, I haven't had a lot of time myself to play around with the new script/report setup in 3.5.0, so another maintainer might be able to shine more light on the intended workflow.
Author
Owner

@arthanson commented on GitHub (May 3, 2023):

To clarify the reproduction steps here:

"Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up"

This is by design. To add scripts in 3.5 you need to add them in the UI.

For the second issue, to reproduce:

  1. have a script in NetBox v3.4 in the scripts directory
  2. Do an upgrade to v3.5
  3. Delete the script (after doing the upgrade)
  4. Go to the scripts page and see the error
@arthanson commented on GitHub (May 3, 2023): To clarify the reproduction steps here: "Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up" This is by design. To add scripts in 3.5 you need to add them in the UI. For the second issue, to reproduce: 1. have a script in NetBox v3.4 in the scripts directory 2. Do an upgrade to v3.5 3. Delete the script (after doing the upgrade) 4. Go to the scripts page and see the error
Author
Owner

@parkerschoenig commented on GitHub (May 4, 2023):

To clarify the reproduction steps here:

"Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up"

This is by design. To add scripts in 3.5 you need to add them in the UI.

For the second issue, to reproduce:

  1. have a script in NetBox v3.4 in the scripts directory
  2. Do an upgrade to v3.5
  3. Delete the script (after doing the upgrade)
  4. Go to the scripts page and see the error

Correct, yes - to fix this, I re-added the script via CLI back into /opt/netbox/netbox/scripts, then deleted it via the UI. Then, re-added it via the UI and all looks good.

However, I have ran into another error that I will open a different bug report for. If you upload a script that by chance has an error, such as an indentation error, or in this example an undefined variable, you will get the following error message for after the upload:

<class 'NameError'>

name 'StringVar' is not defined

Python version: 3.8.10
NetBox version: 3.5.0

Then if you access the Scripts tab in the UI you will be presented with that error, so there is no way to delete it or view other scripts. The fix is to either edit and fix the script in /opt/netbox/netbox/scripts or remove all the contents from the script itself and then you should be able to access the scripts tab again.

@parkerschoenig commented on GitHub (May 4, 2023): > To clarify the reproduction steps here: > > "Access Scripts tab on Web UI, newly added script that was put into /opt/netbox/netbox/scripts does not show up" > > This is by design. To add scripts in 3.5 you need to add them in the UI. > > For the second issue, to reproduce: > > 1. have a script in NetBox v3.4 in the scripts directory > 2. Do an upgrade to v3.5 > 3. Delete the script (after doing the upgrade) > 4. Go to the scripts page and see the error Correct, yes - to fix this, I re-added the script via CLI back into /opt/netbox/netbox/scripts, then deleted it via the UI. Then, re-added it via the UI and all looks good. However, I have ran into another error that I will open a different bug report for. If you upload a script that by chance has an error, such as an indentation error, or in this example an undefined variable, you will get the following error message for after the upload: <class 'NameError'> name 'StringVar' is not defined Python version: 3.8.10 NetBox version: 3.5.0 Then if you access the Scripts tab in the UI you will be presented with that error, so there is no way to delete it or view other scripts. The fix is to either edit and fix the script in /opt/netbox/netbox/scripts or remove all the contents from the script itself and then you should be able to access the scripts tab again.
Author
Owner

@arthanson commented on GitHub (May 4, 2023):

@parkerschoenig I've got a pending PR in that should hopefully fix both these issues.

@arthanson commented on GitHub (May 4, 2023): @parkerschoenig I've got a pending PR in that should hopefully fix both these issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7973