AttributeError in auto_sync signal #8133

Closed
opened 2025-12-29 20:32:50 +01:00 by adam · 0 comments
Owner

Originally created by @miaow2 on GitHub (May 29, 2023).

Originally assigned to: @abhi1693 on GitHub.

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

Originally created by @miaow2 on GitHub (May 29, 2023). Originally assigned to: @abhi1693 on GitHub. ### 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
adam added the type: bugstatus: accepted labels 2025-12-29 20:32:50 +01:00
adam closed this issue 2025-12-29 20:32:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8133