Skip to content

AttributeError in auto_sync signal #12750

@miaow2

Description

@miaow2

NetBox version

v3.5.2

Python version

3.10

Steps to Reproduce

  1. create DataSource with type local or git
  2. sync datasource
  3. create script from any file from datasource, auto sync must be enabled
  4. delete script
  5. sync datasource

Expected Behavior

Sync job will have Completed status

Observed Behavior

Job with DataSource sync will fail, because of AttributeError in signal auto_sync

Log in rqworker

[Job 2d561d69-63b6-4da4-aabb-0bbff4daef29]: exception raised while executing (core.jobs.sync_datasource)
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1418, in perform_job
    rv = job.perform()
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1225, in perform
    self._result = self._execute()
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1262, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/opt/netbox/netbox/core/jobs.py", line 33, in sync_datasource
    raise e
  File "/opt/netbox/netbox/core/jobs.py", line 20, in sync_datasource
    datasource.sync()
  File "/opt/netbox/netbox/core/models/data.py", line 202, in sync
    post_sync.send(sender=self.__class__, instance=self)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/opt/netbox/netbox/core/signals.py", line 21, in auto_sync
    autosync.object.sync(save=True)
AttributeError: 'NoneType' object has no attribute 'sync'

This happens because AutoSyncRecord object does not cascade deleted after ManagedFile object is deleted

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions