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

IPAddress with assigned_object_type_id set, but no assigned_object #1123

Closed
sirtux opened this issue Dec 4, 2021 · 1 comment · Fixed by #1592
Closed

IPAddress with assigned_object_type_id set, but no assigned_object #1123

sirtux opened this issue Dec 4, 2021 · 1 comment · Fixed by #1592
Assignees
Labels
type: bug Something isn't working as expected

Comments

@sirtux
Copy link
Contributor

sirtux commented Dec 4, 2021

Environment

  • Python version: 3.9.5
  • Nautobot version: 1.1.5

Steps to Reproduce

Unclear, all changes to IP objects are done via API,
and I have no idea what exactly caused this to happen

Expected Behavior

Any IPAddress with assigned_object_type_id set should have an assigned_object

Observed Behavior

>>> foo = IPAddress.objects.get(id='6f06b711-1273-44a1-a2d4-a94a9ce82f36')
>>> pp.pprint(vars(foo))
{   '_custom_field_data': {'ASN': None},
    '_django_version': '3.1.13',
    '_state': <django.db.models.base.ModelState object at 0x7fc6837e1a90>,
    'assigned_object_id': None,
    'assigned_object_type_id': 86,
    'broadcast': '1.1.1.1',
    'created': datetime.date(2021, 11, 30),
    'description': '',
    'dns_name': '',
    'host': '1.1.1.1',
    'id': UUID('6f06b711-1273-44a1-a2d4-a94a9ce82f36'),
    'last_updated': datetime.datetime(2021, 12, 4, 10, 27, 49, 79927, tzinfo=<UTC>),
    'nat_inside_id': None,
    'prefix_length': 32,
    'role': '',
    'status_id': UUID('c0a02630-58a1-478a-aea4-04b084ace732'),
    'tenant_id': UUID('acd560e2-22df-4835-95b3-ef1e00f94ca0'),
    'vrf_id': UUID('4e10b062-971e-44af-97a5-be52f41c86b9')}
@glennmatthews
Copy link
Contributor

It does look like the PUT/PATCH REST API allows assigned_object_type and assigned_object_id to be set as separate fields, and I don't see at a glance any logic in the model clean method that checks that either both are null or both are non-null, so it looks like this should be pretty easy to recreate intentionally.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Dec 13, 2021
@lampwins lampwins added this to the v1.3.0 milestone Mar 7, 2022
@bryanculver bryanculver removed this from the v1.3.0 milestone Mar 7, 2022
@timizuoebideri1 timizuoebideri1 self-assigned this Mar 31, 2022
bryanculver added a commit that referenced this issue Apr 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants