Unable to add script #11112

Closed
opened 2025-12-29 21:40:27 +01:00 by adam · 5 comments
Owner

Originally created by @SanderDelden on GitHub (May 2, 2025).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.3.0

Python Version

3.12

Steps to Reproduce

After upgrading to 4.3.0 I'm unable to add a custom script to Netbox. Syncing the datasource works as expected but adding the script throws an exception. When I downgrade to 4.2.9 everything works again.

Seems to be related to the changes introduced with: https://github.com/netbox-community/netbox/pull/18680/

Expected Behavior

Script was added and can be executed from UI.

Observed Behavior

Image
Originally created by @SanderDelden on GitHub (May 2, 2025). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.3.0 ### Python Version 3.12 ### Steps to Reproduce After upgrading to 4.3.0 I'm unable to add a custom script to Netbox. Syncing the datasource works as expected but adding the script throws an exception. When I downgrade to 4.2.9 everything works again. Seems to be related to the changes introduced with: https://github.com/netbox-community/netbox/pull/18680/ ### Expected Behavior Script was added and can be executed from UI. ### Observed Behavior <img width="765" alt="Image" src="https://github.com/user-attachments/assets/51675e70-693a-45dd-ade2-1afb8c2f205b" />
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 21:40:27 +01:00
adam closed this issue 2025-12-29 21:40:27 +01:00
Author
Owner

@arthanson commented on GitHub (May 2, 2025):

@SanderDelden I'm not seeing this, what is your STORAGE_CONFIG, STORAGE_BACKEND settings in config.py (if you haven't migrated to STORAGES) or STORAGES (if you have switched over) or are you using the defaults?

@arthanson commented on GitHub (May 2, 2025): @SanderDelden I'm not seeing this, what is your STORAGE_CONFIG, STORAGE_BACKEND settings in config.py (if you haven't migrated to STORAGES) or STORAGES (if you have switched over) or are you using the defaults?
Author
Owner

@jamiereid commented on GitHub (May 5, 2025):

Seemingly related - syncing of existing git repos break if you have a script linked to a git repo data source.

I removed all the scripts, and the data source would sync again - however I hit the error when attempting to add them back.

<class 'AttributeError'>

'ScriptModule' object has no attribute 'data'

Python version: 3.12.3
NetBox version: 4.3.0-Docker-3.3.0
Plugins: 
  netbox_branching: 0.5.4
@jamiereid commented on GitHub (May 5, 2025): Seemingly related - syncing of existing git repos break if you have a script linked to a git repo data source. I removed all the scripts, and the data source would sync again - however I hit the error when attempting to add them back. ``` <class 'AttributeError'> 'ScriptModule' object has no attribute 'data' Python version: 3.12.3 NetBox version: 4.3.0-Docker-3.3.0 Plugins: netbox_branching: 0.5.4 ```
Author
Owner

@arthanson commented on GitHub (May 5, 2025):

@jamiereid can you please provide a reproduction scenario.

@arthanson commented on GitHub (May 5, 2025): @jamiereid can you please provide a reproduction scenario.
Author
Owner

@SanderDelden commented on GitHub (May 6, 2025):

@arthanson Apologies for the later reply (may 5th was a national holiday here), I have not set both STORAGE_CONFIG and STORAGE_BACKEND. My issue occurs both with a local and Git data source.

I've created a reproduction scenario here: https://github.com/SanderDelden/netbox-issue-19381 please let me know if anything else is needed from my side.

@SanderDelden commented on GitHub (May 6, 2025): @arthanson Apologies for the later reply (may 5th was a national holiday here), I have not set both `STORAGE_CONFIG` and `STORAGE_BACKEND`. My issue occurs both with a local and Git data source. I've created a reproduction scenario here: https://github.com/SanderDelden/netbox-issue-19381 please let me know if anything else is needed from my side.
Author
Owner

@arthanson commented on GitHub (May 6, 2025):

  1. Create Git Data Source that has scripts - I used (https://github.com/bogdancordos/netbox_scripts)
  2. Sync data source
  3. Add new script - choose data source (the one created above)
  4. Choose file from data source
  5. Click Create - get error below
Traceback (most recent call last):
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/object_views.py", line 185, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/netbox/utilities/views.py", line 125, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/netbox/utilities/views.py", line 39, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/object_views.py", line 281, in post
    if form.is_valid():
       ~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 206, in is_valid
    return self.is_bound and not self.errors
                                 ^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 201, in errors
    self.full_clean()
    ~~~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 339, in full_clean
    self._post_clean()
    ~~~~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/forms/base.py", line 78, in _post_clean
    return super()._post_clean()
           ~~~~~~~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/models.py", line 498, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/db/models/base.py", line 1654, in full_clean
    self.clean()
    ~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 110, in clean
    super().clean()
    ~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/models/features.py", line 532, in clean
    self.sync()
    ~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/netbox/models/features.py", line 597, in sync
    self.sync_data()
    ~~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/extras/models/scripts.py", line 183, in sync_data
    super().sync_data()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 91, in sync_data
    self._write_to_disk(self.full_path, overwrite=True)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 103, in _write_to_disk
    new_file.write(self.data)
                   ^^^^^^^^^
AttributeError: 'ScriptModule' object has no attribute 'data'

@arthanson commented on GitHub (May 6, 2025): 1. Create Git Data Source that has scripts - I used (https://github.com/bogdancordos/netbox_scripts) 2. Sync data source 3. Add new script - choose data source (the one created above) 4. Choose file from data source 5. Click Create - get error below ``` Traceback (most recent call last): File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/object_views.py", line 185, in dispatch return super().dispatch(request, *args, **kwargs) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/netbox/utilities/views.py", line 125, in dispatch return super().dispatch(request, *args, **kwargs) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/netbox/utilities/views.py", line 39, in dispatch return super().dispatch(request, *args, **kwargs) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, *args, **kwargs) File "/Users/ahanson/dev/work/netbox/netbox/netbox/views/generic/object_views.py", line 281, in post if form.is_valid(): ~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 206, in is_valid return self.is_bound and not self.errors ^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 201, in errors self.full_clean() ~~~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/forms.py", line 339, in full_clean self._post_clean() ~~~~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/netbox/forms/base.py", line 78, in _post_clean return super()._post_clean() ~~~~~~~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/forms/models.py", line 498, in _post_clean self.instance.full_clean(exclude=exclude, validate_unique=False) ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/venv/lib/python3.13/site-packages/django/db/models/base.py", line 1654, in full_clean self.clean() ~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 110, in clean super().clean() ~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/netbox/models/features.py", line 532, in clean self.sync() ~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/netbox/models/features.py", line 597, in sync self.sync_data() ~~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/extras/models/scripts.py", line 183, in sync_data super().sync_data() ~~~~~~~~~~~~~~~~~^^ File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 91, in sync_data self._write_to_disk(self.full_path, overwrite=True) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahanson/dev/work/netbox/netbox/core/models/files.py", line 103, in _write_to_disk new_file.write(self.data) ^^^^^^^^^ AttributeError: 'ScriptModule' object has no attribute 'data' ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11112