ValueError: 'role' does not resolve to an item that supports prefetching error when selecting Prefix -> IP Addresses #5871

Closed
opened 2025-12-29 19:33:39 +01:00 by adam · 8 comments
Owner

Originally created by @bmhughes on GitHub (Jan 3, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1.4

Python version

3.9

Steps to Reproduce

  1. Upgrade to 3.1.4
  2. Open an IPAM prefix.
  3. Select the IP address tab.
  4. Traceback is observed.

Expected Behavior

The prefix IP address page should have been rendered.

Observed Behavior

A server error is returned with the following traceback.

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic.py", line 124, in get
    table = self.table(self.prep_table_data(request, child_objects, instance), user=request.user)
  File "/opt/netbox/netbox/ipam/views.py", line 515, in prep_table_data
    return add_available_ipaddresses(parent.prefix, queryset, parent.is_pool)
  File "/opt/netbox/netbox/ipam/utils.py", line 54, in add_available_ipaddresses
    if not ipaddress_list:
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 284, in __bool__
    self._fetch_all()
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 1326, in _fetch_all
    self._prefetch_related_objects()
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 813, in _prefetch_related_objects
    prefetch_related_objects(self._result_cache, *self._prefetch_related_lookups)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 1721, in prefetch_related_objects
    raise ValueError("'%s' does not resolve to an item that supports "
ValueError: 'role' does not resolve to an item that supports prefetching - this is an invalid parameter to prefetch_related().
Originally created by @bmhughes on GitHub (Jan 3, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1.4 ### Python version 3.9 ### Steps to Reproduce 1. Upgrade to 3.1.4 2. Open an IPAM prefix. 3. Select the IP address tab. 4. Traceback is observed. ### Expected Behavior The prefix IP address page should have been rendered. ### Observed Behavior A server error is returned with the following traceback. ```python Traceback (most recent call last): File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic.py", line 124, in get table = self.table(self.prep_table_data(request, child_objects, instance), user=request.user) File "/opt/netbox/netbox/ipam/views.py", line 515, in prep_table_data return add_available_ipaddresses(parent.prefix, queryset, parent.is_pool) File "/opt/netbox/netbox/ipam/utils.py", line 54, in add_available_ipaddresses if not ipaddress_list: File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 284, in __bool__ self._fetch_all() File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 1326, in _fetch_all self._prefetch_related_objects() File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 813, in _prefetch_related_objects prefetch_related_objects(self._result_cache, *self._prefetch_related_lookups) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/models/query.py", line 1721, in prefetch_related_objects raise ValueError("'%s' does not resolve to an item that supports " ValueError: 'role' does not resolve to an item that supports prefetching - this is an invalid parameter to prefetch_related(). ```
adam added the type: bugstatus: accepted labels 2025-12-29 19:33:39 +01:00
adam closed this issue 2025-12-29 19:33:39 +01:00
Author
Owner

@candlerb commented on GitHub (Jan 3, 2022):

I see this too, URL is /ipam/prefixes/NNN/ip-addresses/

Temporary workaround: navigate to /ipam/ip-addresses/?parent=1.2.3.0%2F24

@candlerb commented on GitHub (Jan 3, 2022): I see this too, URL is `/ipam/prefixes/NNN/ip-addresses/` Temporary workaround: navigate to `/ipam/ip-addresses/?parent=1.2.3.0%2F24`
Author
Owner

@jeremystretch commented on GitHub (Jan 3, 2022):

FYI this is not related to #8196, it just had not been reported.

@jeremystretch commented on GitHub (Jan 3, 2022): FYI this is not related to #8196, it just had not been reported.
Author
Owner

@bmhughes commented on GitHub (Jan 3, 2022):

FYI this is not related to #8196, it just had not been reported.

Apologies, bad wording on my part there. Will remove it as it's not relevant in hindsight.

@bmhughes commented on GitHub (Jan 3, 2022): > FYI this is not related to #8196, it just had not been reported. Apologies, bad wording on my part there. Will remove it as it's not relevant in hindsight.
Author
Owner

@saruter commented on GitHub (Jan 4, 2022):

I can confirm this bug.
Upgraded to 3.1.4 an getting the same error when opening a prefix with used ip-addresses and getting:


'role' does not resolve to an item that supports prefetching - this is an invalid parameter to prefetch_related().

Python version: 3.8.12
NetBox version: 3.1.4``

Path is for example /ipam/prefixes/2960/ip-addresses/

Prefixes without ip addresses are working fine.

@saruter commented on GitHub (Jan 4, 2022): I can confirm this bug. Upgraded to 3.1.4 an getting the same error when opening a prefix with used ip-addresses and getting: ```<class 'ValueError'> 'role' does not resolve to an item that supports prefetching - this is an invalid parameter to prefetch_related(). Python version: 3.8.12 NetBox version: 3.1.4`` ``` Path is for example /ipam/prefixes/2960/ip-addresses/ Prefixes without ip addresses are working fine.
Author
Owner

@geor-g commented on GitHub (Jan 4, 2022):

Dear people, do you mind attaching emojis to the initial post of this issue, instead of adding 'me too' posts? This would limit the noise for people subscribed to this bug.

Thank you, and sorry for this post, which adds to the noise as well.

@geor-g commented on GitHub (Jan 4, 2022): Dear people, do you mind attaching emojis to the initial post of this issue, instead of adding 'me too' posts? This would limit the noise for people subscribed to this bug. Thank you, and sorry for this post, which adds to the noise as well.
Author
Owner

@jchnbckr commented on GitHub (Jan 4, 2022):

Version 3.1.3 is also affected, by this problem.

@jchnbckr commented on GitHub (Jan 4, 2022): Version 3.1.3 is also affected, by this problem.
Author
Owner

@RobinBeismann commented on GitHub (Jan 6, 2022):

Hi @jeremystretch,

sorry to ask, but do you have an idea when you push the next release where this fix will be included? The issue exists on the docker container tagged by latest and therefor already hit quite a few people (including us).

@RobinBeismann commented on GitHub (Jan 6, 2022): Hi @jeremystretch, sorry to ask, but do you have an idea when you push the next release where this fix will be included? The issue exists on the docker container tagged by latest and therefor already hit quite a few people (including us).
Author
Owner

@jeremystretch commented on GitHub (Jan 6, 2022):

@RobinBeismann should have v3.1.5 pushed out shortly.

@jeremystretch commented on GitHub (Jan 6, 2022): @RobinBeismann should have v3.1.5 pushed out shortly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5871