AttributeError when running database-changing Job from nautobot-server runjob --commit
#944
Labels
type: bug
Something isn't working as expected
Environment
Steps to Reproduce
nautobot-server runjob --commit <job>
command to enqueue a Job that will make any change to the database when runsave()
method, an AttributeError is thrown:Expected Behavior
Job to run successfully to completion just as it would if invoked via the UI or REST API
Observed Behavior
Job aborts and is cleaned up.
Initial Analysis
The
runjob
command calls:JobResult.enqueue_job
passes the providedrequest
(in this caseNone
) as a parameter to the enqueuedrun_job
function.When
run_job
runs withcommit=True
, it callswith change_logging(request):
which enables change-logging for all DB changes triggered by the job via the_handle_changed_object
signal._handle_changed_object
expects a validrequest
object that it can retrieve the calling user and request-id from, but since it'sNone
, anAttributeError
is thrown.Possible solutions:
runjob
, create a mock Request object viaweb_request_context
and pass that instead of None_handle_changed_object
to gracefully handle a null Request.IMO option 1 is probably better.
The text was updated successfully, but these errors were encountered: