Script jobs scheduled by LDAP user raise exception #7651

Closed
opened 2025-12-29 20:26:29 +01:00 by adam · 2 comments
Owner

Originally created by @Antasik on GitHub (Feb 17, 2023).

NetBox version

v3.4.4

Python version

3.9

Steps to Reproduce

Found while learning custom scripts:

  1. Login as LDAP user (backend)
  2. Schedule custom script to run
  3. No information about started execution in 'Job Results' view, exception message in syslog

Expected Behavior

If I'm logged in as local 'Admin' user custom script runs without any problems.

Observed Behavior

Exception log, job scheduled by LDAP user:

Feb 17 11:18:00 NetBox01 python3[28574]: [Job 98f328d8-776f-4413-88d9-bf4567e16761]: exception raised while executing ()
Feb 17 11:18:00 NetBox01 python3[28574]: Traceback (most recent call last):
Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 291, in _deserialize_data
Feb 17 11:18:00 NetBox01 python3[28574]: self._func_name, self._instance, self._args, self._kwargs = self.serializer.loads(self. Data)
Feb 17 11:18:00 NetBox01 python3[28574]: AttributeError: Can't get attribute 'NBLDAPBackend' on <module 'netbox.authentication' from '/opt/netbox-3.4.4/netbox/netbox/authentication.py'>
Feb 17 11:18:00 NetBox01 python3[28574]: The above exception was the direct cause of the following exception:
Feb 17 11:18:00 NetBox01 python3[28574]: Traceback (most recent call last):
Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/worker.py", line 1106, in perform_job
Feb 17 11:18:00 NetBox01 python3[28574]: self.prepare_job_execution(job)
Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/worker.py", line 962, in prepare_job_execution
Feb 17 11:18:00 NetBox01 python3[28574]: self.procline(msg.format(job.func_name, job.origin, time.time()))
Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 326, in func_name
Feb 17 11:18:00 NetBox01 python3[28574]: self._deserialize_data()
Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 294, in _deserialize_data
Feb 17 11:18:00 NetBox01 python3[28574]: raise DeserializationError() from e
Feb 17 11:18:00 NetBox01 python3[28574]: rq.exceptions.DeserializationError

Originally created by @Antasik on GitHub (Feb 17, 2023). ### NetBox version v3.4.4 ### Python version 3.9 ### Steps to Reproduce Found while learning custom scripts: 1. Login as LDAP user (backend) 2. Schedule custom script to run 3. No information about started execution in 'Job Results' view, exception message in syslog ### Expected Behavior If I'm logged in as local 'Admin' user custom script runs without any problems. ### Observed Behavior Exception log, job scheduled by LDAP user: Feb 17 11:18:00 NetBox01 python3[28574]: [Job 98f328d8-776f-4413-88d9-bf4567e16761]: exception raised while executing (<DeserializationError>) Feb 17 11:18:00 NetBox01 python3[28574]: Traceback (most recent call last): Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 291, in _deserialize_data Feb 17 11:18:00 NetBox01 python3[28574]: self._func_name, self._instance, self._args, self._kwargs = self.serializer.loads(self. Data) **Feb 17 11:18:00 NetBox01 python3[28574]: AttributeError: Can't get attribute 'NBLDAPBackend' on <module 'netbox.authentication' from '/opt/netbox-3.4.4/netbox/netbox/authentication.py'>** Feb 17 11:18:00 NetBox01 python3[28574]: The above exception was the direct cause of the following exception: Feb 17 11:18:00 NetBox01 python3[28574]: Traceback (most recent call last): Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/worker.py", line 1106, in perform_job Feb 17 11:18:00 NetBox01 python3[28574]: self.prepare_job_execution(job) Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/worker.py", line 962, in prepare_job_execution Feb 17 11:18:00 NetBox01 python3[28574]: self.procline(msg.format(job.func_name, job.origin, time.time())) Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 326, in func_name Feb 17 11:18:00 NetBox01 python3[28574]: self._deserialize_data() Feb 17 11:18:00 NetBox01 python3[28574]: File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 294, in _deserialize_data Feb 17 11:18:00 NetBox01 python3[28574]: raise DeserializationError() from e Feb 17 11:18:00 NetBox01 python3[28574]: rq.exceptions.DeserializationError
adam added the type: bugstatus: revisions needed labels 2025-12-29 20:26:29 +01:00
adam closed this issue 2025-12-29 20:26:29 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Feb 17, 2023):

Please provide proper replication steps. It works fine here with a user logged in via LDAP. Also the traceback provide no indication that this has anything to do with scheduling scripts.

Lastly, it just looks like you haven't installed django-auth-ldap in the venv where you are running your rqworker.

@kkthxbye-code commented on GitHub (Feb 17, 2023): Please provide proper replication steps. It works fine here with a user logged in via LDAP. Also the traceback provide no indication that this has anything to do with scheduling scripts. Lastly, it just looks like you haven't installed django-auth-ldap in the venv where you are running your rqworker.
Author
Owner

@Antasik commented on GitHub (Feb 17, 2023):

Lastly, it just looks like you haven't installed django-auth-ldap in the venv where you are running your rqworker

Yes, You were partly right. I was missing django-auth-ldap at the deployment stage. After installing missing library, I restarted the netbox service (after that logging via LDAP started working) but I didn't restart the netbox-rq service - after this operation everything works fine.

Thank you for your time and support!

@Antasik commented on GitHub (Feb 17, 2023): > Lastly, it just looks like you haven't installed django-auth-ldap in the venv where you are running your rqworker Yes, You were partly right. I was missing django-auth-ldap at the deployment stage. After installing missing library, I restarted the netbox service (after that logging via LDAP started working) but I didn't restart the netbox-rq service - after this operation everything works fine. Thank you for your time and support!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7651