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

self.result missing from Report-class #13470

Closed
hagbarddenstore opened this issue Aug 15, 2023 · 2 comments
Closed

self.result missing from Report-class #13470

hagbarddenstore opened this issue Aug 15, 2023 · 2 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: documentation A change or addition to the documentation

Comments

@hagbarddenstore
Copy link
Contributor

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.

@hagbarddenstore hagbarddenstore added the type: bug A confirmed report of unexpected behavior in the application label Aug 15, 2023
@hagbarddenstore
Copy link
Contributor Author

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

@jeremystretch
Copy link
Member

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 jeremystretch added type: documentation A change or addition to the documentation and removed type: bug A confirmed report of unexpected behavior in the application labels Aug 23, 2023
@jeremystretch jeremystretch self-assigned this Aug 23, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Aug 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: documentation A change or addition to the documentation
Projects
None yet
Development

No branches or pull requests

2 participants