None object has no get_absolute_url #11094

Closed
opened 2025-12-29 21:40:14 +01:00 by adam · 5 comments
Owner

Originally created by @PetrVoronov on GitHub (Apr 28, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.2

Python Version

3.12

Steps to Reproduce

  1. Create an IP without assigning it to some interface.
  2. Try to load table for IP address in web.
  3. Get 500 error.
      Server Error
There was a problem with your request. Please contact an administrator.

The complete exception is provided below:

<class 'AttributeError'>

'NoneType' object has no attribute 'get_absolute_url'

Python version: 3.12.0
NetBox version: 4.2.2
Plugins: None installed

tables/ip.py
linkify=lambda record: record.assigned_object.get_absolute_url(),

Expected Behavior

    linkify=lambda record: record.assigned_object.get_absolute_url() if record.assigned_object else None,

Observed Behavior

500 error

Originally created by @PetrVoronov on GitHub (Apr 28, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.2 ### Python Version 3.12 ### Steps to Reproduce 1. Create an IP without assigning it to some interface. 2. Try to load table for IP address in web. 3. Get 500 error. ``` Server Error There was a problem with your request. Please contact an administrator. The complete exception is provided below: <class 'AttributeError'> 'NoneType' object has no attribute 'get_absolute_url' Python version: 3.12.0 NetBox version: 4.2.2 Plugins: None installed ``` tables/ip.py ` linkify=lambda record: record.assigned_object.get_absolute_url(), ` ### Expected Behavior linkify=lambda record: record.assigned_object.get_absolute_url() if record.assigned_object else None, ### Observed Behavior 500 error
adam added the type: bug label 2025-12-29 21:40:14 +01:00
adam closed this issue 2025-12-29 21:40:14 +01:00
Author
Owner

@jnovinger commented on GitHub (Apr 28, 2025):

@PetrVoronov , I'm not able to reproduce this with the steps you listed. You listed your NetBox version as 4.2.8, but then your error output shows 4.2.2. Please try this against 4.2.8 to make sure it hasn't already been fixed.

Also, since step #2 was vague, I assumed you meant the IP Address list view at /ipam/ip-addresses/. Is that correct? If so, then I cannot reproduce as it works for me on main and 4.2.8. If not, then please let me know which page you mean in step #2.

@jnovinger commented on GitHub (Apr 28, 2025): @PetrVoronov , I'm not able to reproduce this with the steps you listed. You listed your NetBox version as 4.2.8, but then your error output shows 4.2.2. Please try this against 4.2.8 to make sure it hasn't already been fixed. Also, since step #2 was vague, I assumed you meant the IP Address list view at `/ipam/ip-addresses/`. Is that correct? If so, then I cannot reproduce as it works for me on `main` and 4.2.8. If not, then please let me know which page you mean in step #2.
Author
Owner

@PetrVoronov commented on GitHub (Apr 29, 2025):

    nat_outside = columns.ManyToManyColumn(
        linkify_item=True,
        orderable=False,
        verbose_name=_('NAT (Outside)')
    )
    assigned = columns.BooleanColumn(
        accessor='assigned_object_id',
        linkify=lambda record: record.assigned_object.get_absolute_url(),
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
        verbose_name=_('Assigned'),
        false_mark=None
    )
    comments = columns.MarkdownColumn(
        verbose_name=_('Comments'),
    )```.  
@jnovinger Sorry, fixed, version 4.2.2 I've added last one because I've see the same lines of code in source of 4.2.8. I've fixed it using this line:
```    linkify=lambda record: record.assigned_object.get_absolute_url() if record.assigned_object else None,```
on my test env of 4.2.2, I also can't reproduce it on demo.netbox. But I will try to find route cause on my dataset.
@PetrVoronov commented on GitHub (Apr 29, 2025): ```/opt/netbox/netbox/ipam/tables/ip.py, line 344, in <lambda> nat_outside = columns.ManyToManyColumn( linkify_item=True, orderable=False, verbose_name=_('NAT (Outside)') ) assigned = columns.BooleanColumn( accessor='assigned_object_id', linkify=lambda record: record.assigned_object.get_absolute_url(), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ … verbose_name=_('Assigned'), false_mark=None ) comments = columns.MarkdownColumn( verbose_name=_('Comments'), )```. @jnovinger Sorry, fixed, version 4.2.2 I've added last one because I've see the same lines of code in source of 4.2.8. I've fixed it using this line: ``` linkify=lambda record: record.assigned_object.get_absolute_url() if record.assigned_object else None,``` on my test env of 4.2.2, I also can't reproduce it on demo.netbox. But I will try to find route cause on my dataset.
Author
Owner

@PetrVoronov commented on GitHub (Apr 29, 2025):

@jnovinger I've found error and it related only to my dataset, some how I have assigned object id, but without object -

    "assigned_object_type": null,
    "assigned_object_id": 11321,
    "assigned_object": null,
@PetrVoronov commented on GitHub (Apr 29, 2025): @jnovinger I've found error and it related only to my dataset, some how I have assigned object id, but without object - ``` "assigned_object_type": null, "assigned_object_id": 11321, "assigned_object": null, ```
Author
Owner

@PetrVoronov commented on GitHub (Apr 29, 2025):

I've checked my db from previous setup with 3.1.7 and for this ip there is no assigned_object_id, so looks like it was some migration bug.

@PetrVoronov commented on GitHub (Apr 29, 2025): I've checked my db from previous setup with 3.1.7 and for this ip there is no assigned_object_id, so looks like it was some migration bug.
Author
Owner

@PetrVoronov commented on GitHub (Apr 29, 2025):

I don't think that I will reproduce all and find mistake in migration scripts.

@PetrVoronov commented on GitHub (Apr 29, 2025): I don't think that I will reproduce all and find mistake in migration scripts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11094