Skip to content

Unable to add script #19381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SanderDelden opened this issue May 2, 2025 · 5 comments · Fixed by #19418
Closed

Unable to add script #19381

SanderDelden opened this issue May 2, 2025 · 5 comments · Fixed by #19418
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Milestone

Comments

@SanderDelden
Copy link

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: #18680

Expected Behavior

Script was added and can be executed from UI.

Observed Behavior

Image
@SanderDelden SanderDelden added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 2, 2025
@arthanson arthanson added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: needs triage This issue is awaiting triage by a maintainer labels May 2, 2025
@arthanson
Copy link
Collaborator

@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?

@jamiereid
Copy link

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

@arthanson
Copy link
Collaborator

@jamiereid can you please provide a reproduction scenario.

@SanderDelden
Copy link
Author

@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.

@arthanson
Copy link
Collaborator

  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 arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels May 6, 2025
@arthanson arthanson self-assigned this May 6, 2025
@arthanson arthanson added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels May 6, 2025
@jeremystretch jeremystretch added this to the v4.3.1 milestone May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants