self.result missing from Report-class #8469

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

Originally created by @hagbarddenstore on GitHub (Aug 15, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.7

Python version

3.8

Steps to Reproduce

  1. Create a custom report, inheriting from extras.models.Report
  2. Define a post_run function and access self.result within the function

Expected Behavior

The self.result variable should exist according to the documentation:

To perform additional tasks, such as sending an email or calling a webhook, before or after a report is run, extend the pre_run() and/or post_run() methods, respectively. The status of a completed report is available as self.failed and the results object is self.result.

Source: https://docs.netbox.dev/en/stable/customization/reports/#logging

Observed Behavior

Python exception because self.result doesn't exist.

Originally created by @hagbarddenstore on GitHub (Aug 15, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.7 ### Python version 3.8 ### Steps to Reproduce 1. Create a custom report, inheriting from extras.models.Report 2. Define a `post_run` function and access `self.result` within the function ### Expected Behavior The `self.result` variable should exist according to the documentation: ``` To perform additional tasks, such as sending an email or calling a webhook, before or after a report is run, extend the pre_run() and/or post_run() methods, respectively. The status of a completed report is available as self.failed and the results object is self.result. ``` Source: https://docs.netbox.dev/en/stable/customization/reports/#logging ### Observed Behavior Python exception because `self.result` doesn't exist.
adam added the status: acceptedtype: documentation labels 2025-12-29 20:37:08 +01:00
adam closed this issue 2025-12-29 20:37:08 +01:00
Author
Owner

@hagbarddenstore commented on GitHub (Aug 15, 2023):

Earlier versions of the extras.models.Report class had self.result defined. The field is now called self._results.

@hagbarddenstore commented on GitHub (Aug 15, 2023): Earlier versions of the extras.models.Report class had `self.result` defined. The field is now called `self._results`.
Author
Owner

@jeremystretch commented on GitHub (Aug 23, 2023):

Earlier versions of the extras.models.Report class had self.result defined. The field is now called self._results.

This is incorrect: The _results attribute is an internal cache that has always existed. The result attribute is being set on the Report instance by the view. It previously pointed to a ReportResult instance and now points to the most recent Job associated with the report.

That note was added to the documentation six years ago and may never have been technically correct since result was not set except under the view AFAICT. At this point it makes sense to remove that line from the documentation.

@jeremystretch commented on GitHub (Aug 23, 2023): > Earlier versions of the extras.models.Report class had `self.result` defined. The field is now called `self._results`. This is incorrect: The `_results` attribute is an internal cache that has always existed. The `result` attribute is being set on the Report instance by the view. It previously pointed to a ReportResult instance and now points to the most recent Job associated with the report. That note was added to the documentation [six years ago](https://github.com/netbox-community/netbox/commit/5be4b0c4fd1ddcde2c2688bfe49213b3472fcb4f) and may never have been technically correct since `result` was not set except under the view AFAICT. At this point it makes sense to remove that line from the documentation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8469