Problem with merged fields from separate custom scripts #3743

Closed
opened 2025-12-29 18:30:52 +01:00 by adam · 4 comments
Owner

Originally created by @mahomedh on GitHub (Jun 2, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.8.5

Steps to Reproduce

  1. Install the create_vm.py script and the add_services.py scripts (attached as .txt files)
    create_vm.py.txt
    add_services.py.txt

  2. click on create_vm

  3. enter some parameters

  4. click on Run Script

  5. it rejects the entry and displays a whole load of parameters from the add_service script

  6. viewing a fresh create_vm shows the merged fields

Only way to reset it is to restart the netbox service

Expected Behavior

Only the fields for that specific script should show

Observed Behavior

Running of either script results in merging of the fields of both scripts.

This has also been verified on the mailing list

Originally created by @mahomedh on GitHub (Jun 2, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.9 * NetBox version: 2.8.5 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Install the `create_vm.py` script and the `add_services.py` scripts (attached as `.txt` files) [create_vm.py.txt](https://github.com/netbox-community/netbox/files/4718521/create_vm.py.txt) [add_services.py.txt](https://github.com/netbox-community/netbox/files/4718522/add_services.py.txt) 2. click on create_vm 3. enter some parameters 4. click on Run Script 5. it rejects the entry and displays a whole load of parameters from the add_service script 6. viewing a fresh create_vm shows the merged fields Only way to reset it is to restart the netbox service <!-- What did you expect to happen? --> ### Expected Behavior Only the fields for that specific script should show <!-- What happened instead? --> ### Observed Behavior Running of either script results in merging of the fields of both scripts. This has also been verified on the [mailing list](https://groups.google.com/d/msg/netbox-discuss/J0d6gBNPZKM/Pwa3ebJuBwAJ)
adam added the type: bugstatus: accepted labels 2025-12-29 18:30:52 +01:00
adam closed this issue 2025-12-29 18:30:52 +01:00
Author
Owner

@DanSheps commented on GitHub (Jun 4, 2020):

I am able to reproduce this on https://master.netbox.dev, however you need to run one script and then the other script to get the reject. If you just focus on one script there is no issue.

@DanSheps commented on GitHub (Jun 4, 2020): I am able to reproduce this on https://master.netbox.dev, however you need to run one script and then the other script to get the reject. If you just focus on one script there is no issue.
Author
Owner

@DanSheps commented on GitHub (Jun 4, 2020):

from extras.scripts import StringVar, Script
class Test1(Script):
    class Meta:
        name = "Test 1"
        description = "Test some stuff"
        field_order = [
            'vm_name',
        ]

    vm_name = StringVar(label="VM Name")
    def run(self, data, commit):
        self.log_success("Done Test 1")


class Test2(Script):
    class Meta:
        name = "Test 2"
        description = "Test some stuff"
        field_order = [
            'switch_name'
        ]

    switch_name = StringVar(label="Switch Name")

    def run(self, data, commit):
        self.log_success("Done Test 2")

Reproducible with the following code, to simplify testing.

@DanSheps commented on GitHub (Jun 4, 2020): ``` from extras.scripts import StringVar, Script class Test1(Script): class Meta: name = "Test 1" description = "Test some stuff" field_order = [ 'vm_name', ] vm_name = StringVar(label="VM Name") def run(self, data, commit): self.log_success("Done Test 1") class Test2(Script): class Meta: name = "Test 2" description = "Test some stuff" field_order = [ 'switch_name' ] switch_name = StringVar(label="Switch Name") def run(self, data, commit): self.log_success("Done Test 2") ``` Reproducible with the following code, to simplify testing.
Author
Owner

@mahomedh commented on GitHub (Jun 4, 2020):

however you need to run one script and then the other script to get the reject.

Just to add to the above comment, you simply need to navigate to another script, then it's a bit random but it takes between 1 - 5 refreshes (without actually having to run the second script) to see the extra fields. The definite first step though is that you have to run one script then you cannot run any other script after that without a restart.

Please let me know if there's anything I can do to assist (including testing)

@mahomedh commented on GitHub (Jun 4, 2020): > however you need to run one script and then the other script to get the reject. Just to add to the above comment, you simply need to navigate to another script, then it's a bit random but it takes between 1 - 5 refreshes (without actually having to run the second script) to see the extra fields. The definite first step though is that you have to run one script then you cannot run any other script after that without a restart. Please let me know if there's anything I can do to assist (including testing)
Author
Owner

@jeremystretch commented on GitHub (Jun 15, 2020):

This seems to be a byproduct of the change implemented under #4525 to allow scripts to accept initial data.

@jeremystretch commented on GitHub (Jun 15, 2020): This seems to be a byproduct of the change implemented under #4525 to allow scripts to accept initial data.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3743