Skip to content

extras.scripts.all() is broken #676

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

Open
ziggekatten opened this issue Apr 12, 2025 · 1 comment
Open

extras.scripts.all() is broken #676

ziggekatten opened this issue Apr 12, 2025 · 1 comment
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application

Comments

@ziggekatten
Copy link

pynetbox version

v7.4.1

NetBox version

v3.7.5

Python version

3.12

Steps to Reproduce

import pynetbox
nb = pynetbox.api(
    'https://nebboxhost',
    token='secrettoken'
)

scripts = nb.extras.scripts.all()
for script in scripts:
    print(script.name)

Expected Behavior

A list of scripts

Observed Behavior

I will print out the scripts name, but after listing the last script, the following error occurs:

Traceback (most recent call last):
  File "C:\scappy\netbox_ingest.py", line 8, in <module>
    for script in scripts:
  File "C:\scappy\venv\Lib\site-packages\pynetbox\core\response.py", line 127, in __next__
    next(self.response), self.endpoint.api, self.endpoint
    ^^^^^^^^^^^^^^^^^^^
  File "C:\scappy\venv\Lib\site-packages\pynetbox\core\query.py", line 319, in get
    while req["next"]:
          ~~~^^^^^^^^
KeyError: 'next'

Temporary workaround is to use try/except, but it should be fixed

@ziggekatten ziggekatten added the type: bug A confirmed report of unexpected behavior in the application label Apr 12, 2025
@markkuleinio
Copy link
Contributor

Unable to reproduce (testscript[1-4].py, all having name = "TestScript"):

>>> import pynetbox
>>> netbox = pynetbox.api("http://netbox-test.lein.io/", token="xxx")
>>> scripts = netbox.extras.scripts.all()  # .all() is said to be removed in the future, .filter() does the same
>>> for script in scripts:
...     print(script.name)
...
TestScript
TestScript
TestScript
TestScript
>>> pynetbox.__version__
'7.4.1'
>>> netbox.status()["netbox-version"]
'4.2.3'
>>> sys.version
'3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0]'
>>>

Also tried with limit=1.

How many scripts do you have? Compared to that, what does len(netbox.extras.scripts.all()) say?

What else do you think could affect in your case?

@arthanson arthanson added status: under review Further discussion is needed to determine this issue's scope and/or implementation status: revisions needed This issue requires additional information to be actionable and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants