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 created using args host and prefix_length are unable to be retrieved later using address arg #4733

Closed
jmcgill298 opened this issue Oct 31, 2023 · 2 comments
Assignees
Labels
type: bug Something isn't working as expected

Comments

@jmcgill298
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): 1.6.4
  • Python version: 3.8.18
  • Database platform, version: PSQL container
  • Middleware(s):

Steps to Reproduce

  1. Ensure IPAddress does not exist
  2. Create IPAddress via ORM with IPAddress.objects.create(host=<address>, prefix_length=32, status=<status>)
  3. Try to retrieve the address with IPAddress.objects.get(address=<address>/32)

Expected Behavior

I expected the IPAddress to be retrieved

Observed Behavior

Exception nautobot.ipam.models.IPAddress.DoesNotExist was raised

>>> active_status = Status.objects.get(name="Active")
>>> IPAddress.objects.get(address="1.1.1.1/32")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/nautobot/ipam/querysets.py", line 434, in get
    return super().get(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/cacheops/query.py", line 353, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nautobot.ipam.models.IPAddress.DoesNotExist: IPAddress matching query does not exist.
>>> IPAddress.objects.get(host="1.1.1.1", prefix_length=32)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/nautobot/ipam/querysets.py", line 434, in get
    return super().get(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/cacheops/query.py", line 353, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nautobot.ipam.models.IPAddress.DoesNotExist: IPAddress matching query does not exist.

>>> ip_with_host = IPAddress.objects.create(host="1.1.1.1", prefix_length=32, status=active_status)
>>> ip_with_host.validated_save()

>>> IPAddress.objects.get(host="1.1.1.1", prefix_length=32)
<IPAddress: 1.1.1.1/32>

>>> IPAddress.objects.get(address="1.1.1.1/32")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/nautobot/ipam/querysets.py", line 434, in get
    return super().get(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/cacheops/query.py", line 353, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nautobot.ipam.models.IPAddress.DoesNotExist: IPAddress matching query does not exist.
>>> IPAddress.objects.get(address="1.1.1.1")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/nautobot/ipam/querysets.py", line 434, in get
    return super().get(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/cacheops/query.py", line 353, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nautobot.ipam.models.IPAddress.DoesNotExist: IPAddress matching query does not exist.```
@jmcgill298 jmcgill298 added type: bug Something isn't working as expected triage This issue is new and has not been reviewed. labels Oct 31, 2023
@lampwins lampwins removed the triage This issue is new and has not been reviewed. label Nov 3, 2023
@timizuoebideri1 timizuoebideri1 self-assigned this Nov 7, 2023
@glennmatthews
Copy link
Contributor

Fixed in ltm-1.6 by #4770; the VarbinaryField fix from that PR needs to be added to develop as well before closing this.

@glennmatthews
Copy link
Contributor

#4804 is the corresponding PR to develop.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2024
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
Status: Done
Development

No branches or pull requests

5 participants