Script Rest API has no results #8273

Closed
opened 2025-12-29 20:34:34 +01:00 by adam · 6 comments
Owner

Originally created by @jiuka on GitHub (Jun 30, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.4

Python version

3.11

Steps to Reproduce

  1. Save this script into a file called bug.py
from extras.scripts import *


class Bug13061(Script):

    class Meta:
        name = "Demo for Bug13061"
        description = "Demo for Bug13061"

    def run(self, data, commit):
        self.log_success(f"Demo for Bug13061")
  1. Go to https://netbox.example.com/extras/scripts/add/
  2. Upload the bug.py file.
  3. Got to https://netbox.example.com/extras/scripts/bug/Bug13061/
  4. Click on Run Script
  5. Go to https://netbox.example.com/api/extras/scripts/bug.Bug13061/

Expected Behavior

The result should be job result like in the reports endpoint.

Observed Behavior

It is always null.

The job.name is just the name of the script class. When search for the result the script.name
is used and not the class_name therefore no results are found, unless the name ist set to the same value as the class_name.

Originally created by @jiuka on GitHub (Jun 30, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.4 ### Python version 3.11 ### Steps to Reproduce 1. Save this script into a file called `bug.py` ``` from extras.scripts import * class Bug13061(Script): class Meta: name = "Demo for Bug13061" description = "Demo for Bug13061" def run(self, data, commit): self.log_success(f"Demo for Bug13061") ``` 2. Go to https://netbox.example.com/extras/scripts/add/ 3. Upload the `bug.py` file. 4. Got to https://netbox.example.com/extras/scripts/bug/Bug13061/ 5. Click on `Run Script` 6. Go to https://netbox.example.com/api/extras/scripts/bug.Bug13061/ ### Expected Behavior The `result` should be job result like in the reports endpoint. ### Observed Behavior It is always `null`. The [job.name](https://github.com/netbox-community/netbox/blob/develop/netbox/extras/api/views.py#L293C13-L293C21) is just the name of the script class. When search for the result the [script.name ](https://github.com/netbox-community/netbox/blob/develop/netbox/extras/api/views.py#L306C41-L306C52) is used and not the `class_name` therefore no results are found, unless the `name` ist set to the same value as the `class_name`.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:34:34 +01:00
adam closed this issue 2025-12-29 20:34:35 +01:00
Author
Owner

@abhi1693 commented on GitHub (Jun 30, 2023):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@abhi1693 commented on GitHub (Jun 30, 2023): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@jiuka commented on GitHub (Jun 30, 2023):

I hope it is detailed enough.

@jiuka commented on GitHub (Jun 30, 2023): I hope it is detailed enough.
Author
Owner

@bitcollector1 commented on GitHub (Jul 5, 2023):

I have the same issue. Here you can see an example of just (1) of my scripts reported correctly, even though all of them completed successfully.

Screenshot 2023-07-05 at 09 28 52

@bitcollector1 commented on GitHub (Jul 5, 2023): I have the same issue. Here you can see an example of just (1) of my scripts reported correctly, even though all of them completed successfully. ![Screenshot 2023-07-05 at 09 28 52](https://github.com/netbox-community/netbox/assets/50723251/9df5650c-e361-45c5-8cba-2c1530afcbf1)
Author
Owner

@jiuka commented on GitHub (Jul 11, 2023):

Hi @jeremystretch

This fixed the GUI but not the Rest API I made bug about. Should I create a new bug report or do you want to reopen this one?

Regards and many thanks for Netbox

Marius

@jiuka commented on GitHub (Jul 11, 2023): Hi @jeremystretch This fixed the GUI but not the Rest API I made bug about. Should I create a new bug report or do you want to reopen this one? Regards and many thanks for Netbox Marius
Author
Owner

@cholyoak commented on GitHub (Jul 12, 2023):

That's right. There are still inconsistencies in calling .name instead of .class_name in netbox/extras/api/views.py and netbox/extras/management/commands/runscript.py (this affects running scripst from the command line too). I can share a patch if you like.

@cholyoak commented on GitHub (Jul 12, 2023): That's right. There are still inconsistencies in calling `.name` instead of `.class_name` in `netbox/extras/api/views.py` and `netbox/extras/management/commands/runscript.py` (this affects running scripst from the command line too). I can share a patch if you like.
Author
Owner

@jsenecal commented on GitHub (Jul 12, 2023):

This fixed the GUI but not the Rest API I made bug about. Should I create a new bug report or do you want to reopen this one?

Regards and many thanks for Netbox

Marius

@jiuka Please open a new bug report with a reference to this issue as this has been merged into a release.
Thanks,

@cholyoak you could chime in that other issue should your comment be relevant to that issue as well.

@jsenecal commented on GitHub (Jul 12, 2023): > This fixed the GUI but not the Rest API I made bug about. Should I create a new bug report or do you want to reopen this one? > > Regards and many thanks for Netbox > > Marius @jiuka Please open a new bug report with a reference to this issue as this has been merged into a release. Thanks, @cholyoak you could chime in that other issue should your comment be relevant to that issue as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8273