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

Exception for job list if object not set #17682

Closed
alehaa opened this issue Oct 6, 2024 · 2 comments
Closed

Exception for job list if object not set #17682

alehaa opened this issue Oct 6, 2024 · 2 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@alehaa
Copy link
Contributor

alehaa commented Oct 6, 2024

Deployment Type

Self-hosted

NetBox Version

v4.1.3

Python Version

3.11

Steps to Reproduce

  1. Create a new JobRunner.
  2. Schedule the job runner without an instance being passed to enqueue_once().
  3. Navigate to jobs list view

Expected Behavior

List is shown

Observed Behavior

AttributeError at /core/jobs/

'NoneType' object has no attribute 'model'

This seems to be similar to #17086, but I don't know why it wasn't observed in previous versions.

As this blocks implementation of #16971 or at least makes the changes impractical to use, I'd like to check on this issue first (and volunteer for a PR).

@alehaa alehaa added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 6, 2024
@alehaa
Copy link
Contributor Author

alehaa commented Oct 7, 2024

In core.Job, object_type is optional. However, its get_absolute_url() method assumes it not to be None. Required changes:

diff --git a/netbox/core/models/jobs.py b/netbox/core/models/jobs.py
index 4a327a1d8..499822468 100644
--- a/netbox/core/models/jobs.py
+++ b/netbox/core/models/jobs.py
@@ -118,9 +118,9 @@ class Job(models.Model):
 
     def get_absolute_url(self):
         # TODO: Employ dynamic registration
-        if self.object_type.model == 'reportmodule':
+        if self.object_type and self.object_type.model == 'reportmodule':
             return reverse(f'extras:report_result', kwargs={'job_pk': self.pk})
-        if self.object_type.model == 'scriptmodule':
+        if self.object_type and self.object_type.model == 'scriptmodule':
             return reverse(f'extras:script_result', kwargs={'job_pk': self.pk})
         return reverse('core:job', args=[self.pk])

@alehaa
Copy link
Contributor Author

alehaa commented Oct 7, 2024

I believe this is a duplicate of #17566. Sorry.

@alehaa alehaa closed this as completed Oct 7, 2024
@jeremystretch jeremystretch removed the status: needs triage This issue is awaiting triage by a maintainer label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants