Server error by opening a report: 'list' object has no attribute 'stip' #6857

Closed
opened 2025-12-29 19:46:07 +01:00 by adam · 0 comments
Owner

Originally created by @maxhandschild on GitHub (Aug 23, 2022).

NetBox version

v3.3.0

Python version

3.8

Steps to Reproduce

I wrote a report in Python and when I ran it, the script just loaded.
When I go back to the overview, I see that the report has run. When I then display the report, the following error appears:
image
I reduced the report to the problematic lines, then it looks like this:

from extras.reports import Report
from virtualization.models import VirtualMachine

class Test(Report):

  def method():
    srv_list = [ vm.name
      for vm in VirtualMachine.objects.all()
    ]
    return srv_list
  def test_test(self):
    self.log_warning('test',Test.method())

Expected Behavior

I want to get a list of VMs that have previously been filtered for certain attributes.

Observed Behavior

I found a workaround for this issue, but I'm not sure if this causes any problems. So far, my colleagues and I have not been able to identify any problems.
In the file /data/netbox/netbox/utilities/templatetags/builtins/filters.py I made the following changes:

149,161d149
<     schemes = '|'.join(get_config().ALLOWED_URL_SCHEMES)
<
<     # Strip HTML tags
<     value = strip_tags(value)
<
<     # Sanitize Markdown links
<     pattern = fr'\[([^\]]+)\]\(\s*(?!({schemes})).*:(.+)\)'
<     value = re.sub(pattern, '[\\1](\\3)', value, flags=re.IGNORECASE)
<
<     # Sanitize Markdown reference links
<     pattern = fr'\[([^\]]+)\]:\s*(?!({schemes}))\w*:(.+)'
<     value = re.sub(pattern, '[\\1]: \\3', value, flags=re.IGNORECASE)
<
169c157
< #    schemes = get_config().ALLOWED_URL_SCHEMES
---
>     schemes = get_config().ALLOWED_URL_SCHEMES
172c160
< #    html = clean_html(html, schemes)
---
>     html = clean_html(html, schemes)
Originally created by @maxhandschild on GitHub (Aug 23, 2022). ### NetBox version v3.3.0 ### Python version 3.8 ### Steps to Reproduce I wrote a report in Python and when I ran it, the script just loaded. When I go back to the overview, I see that the report has run. When I then display the report, the following error appears: ![image](https://user-images.githubusercontent.com/111870647/186148487-e45f63b0-98b1-4bee-9ff3-22833ddb01dd.png) I reduced the report to the problematic lines, then it looks like this: ``` from extras.reports import Report from virtualization.models import VirtualMachine class Test(Report): def method(): srv_list = [ vm.name for vm in VirtualMachine.objects.all() ] return srv_list def test_test(self): self.log_warning('test',Test.method()) ``` ### Expected Behavior I want to get a list of VMs that have previously been filtered for certain attributes. ### Observed Behavior I found a workaround for this issue, but I'm not sure if this causes any problems. So far, my colleagues and I have not been able to identify any problems. In the file /data/netbox/netbox/utilities/templatetags/builtins/filters.py I made the following changes: ``` 149,161d149 < schemes = '|'.join(get_config().ALLOWED_URL_SCHEMES) < < # Strip HTML tags < value = strip_tags(value) < < # Sanitize Markdown links < pattern = fr'\[([^\]]+)\]\(\s*(?!({schemes})).*:(.+)\)' < value = re.sub(pattern, '[\\1](\\3)', value, flags=re.IGNORECASE) < < # Sanitize Markdown reference links < pattern = fr'\[([^\]]+)\]:\s*(?!({schemes}))\w*:(.+)' < value = re.sub(pattern, '[\\1]: \\3', value, flags=re.IGNORECASE) < 169c157 < # schemes = get_config().ALLOWED_URL_SCHEMES --- > schemes = get_config().ALLOWED_URL_SCHEMES 172c160 < # html = clean_html(html, schemes) --- > html = clean_html(html, schemes) ```
adam closed this issue 2025-12-29 19:46:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6857