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

Possible bug introduced by #6616 - Unable to create nested IP Prefix #6774

Open
gneville-ot opened this issue Jan 14, 2025 · 1 comment
Open
Labels
triage This issue is new and has not been reviewed. type: bug Something isn't working as expected

Comments

@gneville-ot
Copy link

Environment

  • Nautobot version (Docker tag too if applicable): 2.3.15
  • Python version: 3.12
  • Database platform, version: PG15
  • Middleware(s): N/A

Steps to Reproduce

  1. Via the GUI create an IP Prefix of Type 'Container' within the 'Global' Namespace e.g. 1.1.1.0/24
  2. Attempt to use SSoT to create an IP Prefix of Type 'Network' that should belong to the Container from Step 1 e.g. 1.1.1.0/26

Expected Behavior

The new IP Prefix is inserted to the database as a child

Observed Behavior

The insert fails with a python traceback

[2025-01-14 15:09:53,049: ERROR/ForkPoolWorker-7] Task nautobot.extras.jobs.run_job[7f6a5029-9bd9-4512-b848-4384b377542d] raised unexpected: ValueError('Cannot use None as a query value')
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/extras/jobs.py", line 1138, in run_job
    result = job(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/extras/jobs.py", line 151, in __call__
    return self.run(*args, **deserialized_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/git/ot_dcim_data_ssot/jobs/yaml_sync_job.py", line 34, in run
    super().run(dryrun=self.dryrun, memory_profiling=self.memory_profiling, *args, **kwargs)
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nautobot_ssot/jobs/base.py", line 354, in run
    self.sync_data(memory_profiling)
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nautobot_ssot/jobs/base.py", line 196, in sync_data
    self.execute_sync()
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nautobot_ssot/jobs/base.py", line 98, in execute_sync
    self.source_adapter.sync_to(self.target_adapter, flags=self.diffsync_flags)
  File "/opt/nautobot/git/ot_dcim_data_ssot/jobs/diffsync/adapters/otdcimdata.py", line 214, in sync_to
    return super().sync_to(target, diff_class=otdcimdataCustomOrderDiff, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/diffsync/__init__.py", line 626, in sync_to
    return target.sync_from(self, diff_class=diff_class, flags=flags, callback=callback, diff=diff)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/diffsync/__init__.py", line 598, in sync_from
    result = syncer.perform_sync()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/diffsync/helpers.py", line 329, in perform_sync
    changed |= self.sync_diff_element(element)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/diffsync/helpers.py", line 379, in sync_diff_element
    changed, modified_model = self.sync_model(src_model=src_model, dst_model=dst_model, ids=ids, attrs=attrs)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/diffsync/helpers.py", line 428, in sync_model
    dst_model = self.model_class.create(adapter=self.dst_diffsync, ids=ids, attrs=attrs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nautobot_ssot/contrib/model.py", line 105, in create
    cls._update_obj_with_parameters(obj, parameters, adapter)
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nautobot_ssot/contrib/model.py", line 230, in _update_obj_with_parameters
    obj.validated_save()
  File "/usr/local/lib/python3.12/site-packages/nautobot/core/models/__init__.py", line 132, in validated_save
    self.full_clean()
  File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 1477, in full_clean
    self.clean()
  File "/usr/local/lib/python3.12/site-packages/nautobot/extras/plugins/validators.py", line 20, in wrapper
    model_clean_func(model_instance)
  File "/usr/local/lib/python3.12/site-packages/nautobot/ipam/models.py", line 653, in clean
    self.parent = self.get_parent()
                  ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/ipam/models.py", line 644, in get_parent
    if supernets := self.supernets():
                    ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/ipam/models.py", line 802, in supernets
    supernets = query.filter(
                ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/ipam/querysets.py", line 274, in filter
    return super().filter(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/ipam/mixins.py", line 28, in filter
    return super().filter(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot/core/models/querysets.py", line 98, in filter
    return super().filter(*args, **self.split_composite_key_into_kwargs(composite_key, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1436, in filter
    return self._filter_or_exclude(False, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1454, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
  File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1461, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1546, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1577, in _add_q
    child_clause, needed_inner = self.build_filter(
                                 ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1492, in build_filter
    condition = self.build_lookup(lookups, col, value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1324, in build_lookup
    raise ValueError("Cannot use None as a query value")
ValueError: Cannot use None as a query value

This was working previously with nautobot version 2.3.4 but has become an issue with nautobot 2.3.15 and looks to be related to code introduced in #6616.
It does work via the GUI just not an SSoT App.

@gneville-ot gneville-ot added triage This issue is new and has not been reviewed. type: bug Something isn't working as expected labels Jan 14, 2025
@glennmatthews
Copy link
Contributor

May be a duplicate of #6738.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage This issue is new and has not been reviewed. type: bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants