Custom scripts in symlinked path don't work #11261

Closed
opened 2025-12-29 21:42:37 +01:00 by adam · 3 comments
Owner

Originally created by @llamafilm on GitHub (Jun 5, 2025).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.3.1

Python Version

3.10

Steps to Reproduce

  1. Install Netbox 4.3.1, following the instructions to use a symlinked path /opt/netbox
  2. Create a custom script from the /extras/scripts/add webpage
  3. Run the script

Expected Behavior

it should work

Observed Behavior

Script fails with no error message shown.

When you enable debug level logging for netbox.data_backends it shows this:

netbox.data_backends[9596]: Failed to load script: connect_power error: The joined path (/opt/netbox/netbox/scripts/connect_power.py) is located outside of the base path component (/opt/netbox-4.3.1/netbox/scripts)

Image

I first saw this issue on my prod Netbox after upgrading to 4.3.1 and creating a new script. All my old scripts still work fine. I reproduced the issue on a fresh install. In this case, I didn't customize anything, just used all the defaults, including the recommendation for symlinking /opt/netbox.

Here is the difference between the new broken script and an older, working script on my prod instance:

netbox=> SELECT id,data_path,file_path,data_file_id,data_source_id,auto_sync_enabled FROM core_managedfile ORDER BY CREATED DESC LIMIT 2;
 id  |             data_path              |                  file_path                  | data_file_id | data_source_id | auto_sync_enabled 
-----+------------------------------------+---------------------------------------------+--------------+----------------+-------------------
 208 |                                    | /opt/netbox/netbox/scripts/connect_power.py |              |                | f
 206 | scripts/import_terrier_mactable.py | import_terrier_mactable.py                  |         7727 |             35 | t
Originally created by @llamafilm on GitHub (Jun 5, 2025). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.3.1 ### Python Version 3.10 ### Steps to Reproduce 1. Install Netbox 4.3.1, following the [instructions](https://netboxlabs.com/docs/netbox/installation/netbox/) to use a symlinked path `/opt/netbox` 2. Create a custom script from the `/extras/scripts/add` webpage 3. Run the script ### Expected Behavior it should work ### Observed Behavior Script fails with no error message shown. When you enable debug level logging for `netbox.data_backends` it shows this: > netbox.data_backends[9596]: Failed to load script: connect_power error: The joined path (/opt/netbox/netbox/scripts/connect_power.py) is located outside of the base path component (/opt/netbox-4.3.1/netbox/scripts) ![Image](https://github.com/user-attachments/assets/936ca0b7-aae8-4132-a989-77f715fe62df) I first saw this issue on my prod Netbox after upgrading to 4.3.1 and creating a new script. All my old scripts still work fine. I reproduced the issue on a fresh install. In this case, I didn't customize anything, just used all the defaults, including the recommendation for symlinking `/opt/netbox`. Here is the difference between the new broken script and an older, working script on my prod instance: ``` netbox=> SELECT id,data_path,file_path,data_file_id,data_source_id,auto_sync_enabled FROM core_managedfile ORDER BY CREATED DESC LIMIT 2; id | data_path | file_path | data_file_id | data_source_id | auto_sync_enabled -----+------------------------------------+---------------------------------------------+--------------+----------------+------------------- 208 | | /opt/netbox/netbox/scripts/connect_power.py | | | f 206 | scripts/import_terrier_mactable.py | import_terrier_mactable.py | 7727 | 35 | t ```
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 21:42:37 +01:00
adam closed this issue 2025-12-29 21:42:38 +01:00
Author
Owner

@llamafilm commented on GitHub (Jun 5, 2025):

I was able to workaround this by just changing the file_path. I left data_path blank, I'm not sure if that matters.

UPDATE core_managedfile SET file_path = 'connect_power.py' WHERE id = 208;
@llamafilm commented on GitHub (Jun 5, 2025): I was able to workaround this by just changing the file_path. I left data_path blank, I'm not sure if that matters. ```sql UPDATE core_managedfile SET file_path = 'connect_power.py' WHERE id = 208; ```
Author
Owner

@arthanson commented on GitHub (Jun 13, 2025):

This should be fixed by #19698

@arthanson commented on GitHub (Jun 13, 2025): This should be fixed by #19698
Author
Owner

@jnovinger commented on GitHub (Jun 13, 2025):

I'm going to go ahead and close this as a duplicate, as Arthur references. If it turns out to be a separate issue, we can re-open.

@jnovinger commented on GitHub (Jun 13, 2025): I'm going to go ahead and close this as a duplicate, as Arthur references. If it turns out to be a separate issue, we can re-open.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11261