Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when selcting to view IP address details #18288

Closed
KaleBrink opened this issue Jan 2, 2025 · 6 comments · Fixed by #18298
Closed

Error when selcting to view IP address details #18288

KaleBrink opened this issue Jan 2, 2025 · 6 comments · Fixed by #18298
Assignees
Labels
beta Concerns a bug/feature in a beta release severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@KaleBrink
Copy link

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.2 beta

Python Version

3.12

Steps to Reproduce

Create al the necessary IPAM information to enable you to create an IP address. Assign them to a site and region, then create an IP address. When you then select the IP address from IP addresses the error below is shown.

Same error occurs when creating an IP address form the IP address menu.

`<class 'AttributeError'>

'Site' object has no attribute 'scope_id'

Python version: 3.12.3
NetBox version: 4.2-beta1
Plugins: None installed`

Expected Behavior

I would expect to see all details of the IP address selected.

Observed Behavior

<class 'AttributeError'>

'Site' object has no attribute 'scope_id'

Python version: 3.12.3
NetBox version: 4.2-beta1
Plugins: None installed

@KaleBrink KaleBrink added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Jan 2, 2025
@jeremystretch jeremystretch added the beta Concerns a bug/feature in a beta release label Jan 2, 2025
@bctiemann
Copy link
Contributor

@KaleBrink I think I need more info in order to reproduce this --

Create al the necessary IPAM information to enable you to create an IP address. Assign them to a site and region, then create an IP address.

What does "all the necessary IPAM information" mean? Which objects need to be created?
In "Assign them to a site and region", what does "them" refer to?

Same error occurs when creating an IP address form the IP address menu.

Which IP address menu is this? Is it the inline "IP Addresses" table on the Interface detail page, with the "+ Add IP Address" button? A screenshot would help.

I'm not able to reproduce this error creating IP addresses on any of the devices/interfaces in the demo data set (which have a Site assigned). Please provide some specific actionable reproduction steps. Thanks!

@bctiemann bctiemann added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Jan 2, 2025
@KaleBrink
Copy link
Author

@bctiemann I have created a RIR (RFC 1918). I have added an aggregate (10.0.0.0/8). Then I have added the prefix 10.0.10.0/24 twice, each assigned to a different Tenant. Then I have assigned IP 10.010.1 to a device from tenant 1 and 10.0.10.2 to a device from tenant 2. When I click on the IP address it should show me an overview of all the details from that IP address, but instead I get the error shown in my first post.

@bctiemann
Copy link
Contributor

@KaleBrink Still having trouble following this...

Then I have added the prefix 10.0.10.0/24 twice, each assigned to a different Tenant.

When I try to add the same prefix twice with two different Tenants, I get a validation error on the second one saying "Duplicate prefix found in global table: 10.0.10.0/24". Is it necessary to have two such prefixes in order to reproduce the error?

Then I have assigned IP 10.010.1 to a device from tenant 1 and 10.0.10.2 to a device from tenant 2.

How are you assigning the IPs to these Devices? What kind of devices are they? Do they have Sites defined? Are you going to the detail page of an Interface on the Device in question and then adding the IP address via the inline table I mentioned in my last comment? Again, screenshots would be very helpful here.

I've created all the objects you've described here (aside from the duplicate/overlapping prefixes) and assigned the IP to the device as indicated, and I'm not getting any error.

Please provide minimal, step-by-step, unambiguous reproduction steps (with specifics such as object names and associations) that you can verify will result in the error on a fresh install of the app. Please provide screenshots or other complete representations of all objects that you have created. Thanks ...

@bctiemann
Copy link
Contributor

@KaleBrink Another thing that might help (since we're releasing v4.2 on Monday and I'd like to get this fixed ASAP) - could you turn on DEBUG = True and post the complete stack trace? That would probably allow us to see the root cause more quickly than setting up data to match your environment.

@KaleBrink
Copy link
Author

KaleBrink commented Jan 3, 2025

@bctiemann Here is the debug information. I hope this helps, and that it is not just related to my install.

Environment:


Request Method: GET
Request URL: https://192.168.1.203/ipam/ip-addresses/2/

Django Version: 5.1.3
Python Version: 3.12.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.forms',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_htmx',
 'django_tables2',
 'django_prometheus',
 'strawberry_django',
 'mptt',
 'rest_framework',
 'social_django',
 'taggit',
 'timezone_field',
 'core',
 'account',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'vpn',
 'wireless',
 'django_rq',
 'drf_spectacular',
 'drf_spectacular_sidecar']
Installed Middleware:
['strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django_htmx.middleware.HtmxMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.CoreMiddleware',
 'netbox.middleware.MaintenanceModeMiddleware']



Traceback (most recent call last):
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 77, in get
    **self.get_extra_context(request, instance),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/ipam/views.py", line 811, in get_extra_context
    list(parent_prefixes),
    ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/query.py", line 400, in __iter__
    self._fetch_all()
    ^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1930, in _fetch_all
    self._prefetch_related_objects()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1320, in _prefetch_related_objects
    prefetch_related_objects(self._result_cache, *self._prefetch_related_lookups)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/query.py", line 2380, in prefetch_related_objects
    obj_list, additional_lookups = prefetch_one_level(
                                   
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/query.py", line 2544, in prefetch_one_level
    ) = prefetcher.get_prefetch_querysets(
        
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 799, in get_prefetch_querysets
    instance = instances_dict[rel_obj_attr(rel_obj)]
                              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/fields/related.py", line 748, in get_local_related_value
    return self.get_instance_value_for_fields(instance, self.local_related_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.2-beta1/venv/lib/python3.12/site-packages/django/db/models/fields/related.py", line 770, in get_instance_value_for_fields
    ret.append(getattr(instance, field.attname))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: AttributeError at /ipam/ip-addresses/2/
Exception Value: 'Site' object has no attribute 'scope_id'

@bctiemann
Copy link
Contributor

Thanks! That's got me what I need. I'll have a PR up shortly.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: revisions needed This issue requires additional information to be actionable labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Concerns a bug/feature in a beta release severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
3 participants