Custom Script type output #10314

Closed
opened 2025-12-29 21:29:49 +01:00 by adam · 1 comment
Owner

Originally created by @SRF-rueeggdo on GitHub (Oct 2, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.1.2

Python Version

3.11

Steps to Reproduce

  1. import the custom script below.
  2. Execute the script.
  3. check the logging and the output information
from extras.scripts import *
from dcim.models import DeviceType,


class CreateCable(Script):
    class Meta:
        name = "Create Cable"
        description = "Create a cable"
        commit_default = True
        scheduling_enabled = False

    device_1 = ObjectVar(
        label="Gerät 1",
        description="Wählen Sie ein Gerät.",
        model=Device,
        required=False,
    )

    def run(self, data, commit):
        self.data = data
        self.commit = commit
        self.output = "test"
        self.log_info(f"Type: {type(self.output)}")
        self.log_debug(f"Type: {type(self.output)}")

        return f"Type: {type(self.output)}"

Expected Behavior

I would expect the type() function to be correctly visible in the logging and output area of Netbox. However, it is only visible in the output area.

I have used this function in the past to debug custom scripts.
I used to use Netbox v3.7.1 where it worked.
In versions v4.1.1.1 and v4.1.2 this is apparently no longer the case.

Observed Behavior

It is only visible in the output area.

Screenshot 2024-10-02 141244

Originally created by @SRF-rueeggdo on GitHub (Oct 2, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.1.2 ### Python Version 3.11 ### Steps to Reproduce 1. import the custom script below. 2. Execute the script. 3. check the logging and the output information ```python from extras.scripts import * from dcim.models import DeviceType, class CreateCable(Script): class Meta: name = "Create Cable" description = "Create a cable" commit_default = True scheduling_enabled = False device_1 = ObjectVar( label="Gerät 1", description="Wählen Sie ein Gerät.", model=Device, required=False, ) def run(self, data, commit): self.data = data self.commit = commit self.output = "test" self.log_info(f"Type: {type(self.output)}") self.log_debug(f"Type: {type(self.output)}") return f"Type: {type(self.output)}" ``` ### Expected Behavior I would expect the *type()* function to be correctly visible in the *logging* and *output* area of Netbox. However, it is only visible in the *output* area. I have used this function in the past to debug custom scripts. I used to use Netbox v3.7.1 where it worked. In versions v4.1.1.1 and v4.1.2 this is apparently no longer the case. ### Observed Behavior It is only visible in the *output* area. ![Screenshot 2024-10-02 141244](https://github.com/user-attachments/assets/72c69c16-ea0c-4c2c-bbde-3b712933e582)
adam closed this issue 2025-12-29 21:29:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 2, 2024):

The script's logging methods support HTML output. If you want to output raw Python objects (which are represented with opening and closing angle brackets), you'll need to escape the output to avoid it being rendered as HTML.

@jeremystretch commented on GitHub (Oct 2, 2024): The script's logging methods support HTML output. If you want to output raw Python objects (which are represented with opening and closing angle brackets), you'll need to escape the output to avoid it being rendered as HTML.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10314