Skip to content
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

AttributeError at /api/extras/scripts/8/ can't set attribute 'result' #16123

Closed
MalfuncEddie opened this issue May 14, 2024 · 3 comments · Fixed by #16131
Closed

AttributeError at /api/extras/scripts/8/ can't set attribute 'result' #16123

MalfuncEddie opened this issue May 14, 2024 · 3 comments · Fixed by #16131
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

Comments

@MalfuncEddie
Copy link

Deployment Type

Self-hosted

NetBox Version

v4.0.1

Python Version

3.10

Steps to Reproduce

following:

https://docs.netbox.dev/en/stable/customization/custom-scripts/

curl -X POST -H "Authorization: Token $MY_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" https://netbox-test/api/extras/scripts/8/ --data '{"da
ta": {"foo": "somevalue", "bar": 123}, "commit": true}'

I get the error
AttributeError at /api/extras/scripts/8/
can't set attribute 'result'

Additional question: in the past I could run the script with "https://netbox-test/api/extras/scripts/scriptA.class"
This does not work anymore and I need an ID ;(

May 14 11:42:59 netbox-test uwsgi[640883]: Internal Server Error: /api/extras/scripts/8/
May 14 11:42:59 netbox-test uwsgi[640883]: Traceback (most recent call last):
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
May 14 11:42:59 netbox-test uwsgi[640883]:     response = get_response(request)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
May 14 11:42:59 netbox-test uwsgi[640883]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
May 14 11:42:59 netbox-test uwsgi[640883]:     return view_func(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 124, in view
May 14 11:42:59 netbox-test uwsgi[640883]:     return self.dispatch(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
May 14 11:42:59 netbox-test uwsgi[640883]:     response = self.handle_exception(exc)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
May 14 11:42:59 netbox-test uwsgi[640883]:     self.raise_uncaught_exception(exc)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
May 14 11:42:59 netbox-test uwsgi[640883]:     raise exc
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
May 14 11:42:59 netbox-test uwsgi[640883]:     response = handler(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/netbox/./extras/api/views.py", line 243, in post
May 14 11:42:59 netbox-test uwsgi[640883]:     script.result = Job.enqueue(
May 14 11:42:59 netbox-test uwsgi[640883]: AttributeError: can't set attribute 'result'
May 14 11:42:59 netbox-test uwsgi[640883]: [pid: 640883|app: 0|req: 43/43] 172.31.68.177 () {60 vars in 1061 bytes} [Tue May 14 11:42:59 2024] POST /api/extras/scripts/8/ => generated 23250 bytes in 54 msecs (HTTP/1.1 500) 10 headers in 378 bytes (1 switches on core 0)

PS: upgraded from v3.5.4 -> 3.7.7 -> 4.0.0 -> 4.0.1

Expected Behavior

script is executed successfully

(via gui it does work

Observed Behavior

AttributeError: can't set attribute 'result'

May 14 11:42:59 netbox-test uwsgi[640883]: Internal Server Error: /api/extras/scripts/8/
May 14 11:42:59 netbox-test uwsgi[640883]: Traceback (most recent call last):
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
May 14 11:42:59 netbox-test uwsgi[640883]:     response = get_response(request)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
May 14 11:42:59 netbox-test uwsgi[640883]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
May 14 11:42:59 netbox-test uwsgi[640883]:     return view_func(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 124, in view
May 14 11:42:59 netbox-test uwsgi[640883]:     return self.dispatch(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
May 14 11:42:59 netbox-test uwsgi[640883]:     response = self.handle_exception(exc)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
May 14 11:42:59 netbox-test uwsgi[640883]:     self.raise_uncaught_exception(exc)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
May 14 11:42:59 netbox-test uwsgi[640883]:     raise exc
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
May 14 11:42:59 netbox-test uwsgi[640883]:     response = handler(request, *args, **kwargs)
May 14 11:42:59 netbox-test uwsgi[640883]:   File "/netbox/releases/netbox-4.0.1/netbox/./extras/api/views.py", line 243, in post
May 14 11:42:59 netbox-test uwsgi[640883]:     script.result = Job.enqueue(
May 14 11:42:59 netbox-test uwsgi[640883]: AttributeError: can't set attribute 'result'
May 14 11:42:59 netbox-test uwsgi[640883]: [pid: 640883|app: 0|req: 43/43] 172.31.68.177 () {60 vars in 1061 bytes} [Tue May 14 11:42:59 2024] POST /api/extras/scripts/8/ => generated 23250 bytes in 54 msecs (HTTP/1.1 500) 10 headers in 378 bytes (1 switches on core 0)
@MalfuncEddie MalfuncEddie 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 14, 2024
@MalfuncEddie
Copy link
Author

Hi,

additional info. Reverted to v3.5.4 and did the upgrade again

3.7.7 -> works
4.0.1 -> does not work

@Leon-Pay
Copy link

As provided in #16129 this also breaks the usage of using the script names in the url. And does not reflect in the documentation about custom scripts.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: needs triage This issue is awaiting triage by a maintainer labels May 14, 2024
@jeremystretch jeremystretch self-assigned this May 14, 2024
@MalfuncEddie
Copy link
Author

Hi,

Is it normal behavior that "https://netbox-test/api/extras/scripts/scriptA.class" still does not work?

Field 'id' expected a number but got

with id it does work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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