-
Notifications
You must be signed in to change notification settings - Fork 58
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
Error handling for Generate Report #2274
Conversation
@@ -71,7 +74,13 @@ def setup(self, request, *args, **kwargs): | |||
self.selected_report_types = request.GET.getlist("report_type", []) | |||
|
|||
def get_oois(self) -> List[OOI]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will conflict later, depends on merging prio with:
nl-kat-coordination/rocky/reports/views/base.py
Lines 75 to 84 in 23f95f9
def get_oois(self) -> List[OOI]: | |
if "all" in self.selected_oois: | |
return self.octopoes_api_connector.list( | |
self.get_ooi_types(), | |
valid_time=self.valid_time, | |
limit=OOIList.HARD_LIMIT, | |
scan_level=self.get_ooi_scan_levels(), | |
scan_profile_type=self.get_ooi_profile_types(), | |
).items | |
return [self.get_single_ooi(ooi_id) for ooi_id in self.selected_oois] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestions to improve even more, but should be ready for QA testing
Checklist for QA:
What works:Onboarding flow works, tasks and findings are created. What doesn't work:The 500 errors are catched for the DNS report, but not for all other reports. Bug or feature?:
The URL for the report_type parameter error with 'report_type=dns-repoooort': The URL for the ooi parameter error with 'ooi=Hostnameeeeee|internet|mispo.es':
|
…om/minvws/nl-kat-coordination into fix/error-handling-generate-report
…om/minvws/nl-kat-coordination into fix/error-handling-generate-report
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more remarks
Checklist for QA:
What works:The error handling seems to work as expected, thus it can be merged. The found items can also be solved in separate PRs. What doesn't work:'Normal' report:
Bug or feature?:
|
* main: Fix/394 Introduce clearance level control for objects imported by CSV (#2390) Update RabbitMQ to the latest version (#2392) Show created at and data from in reports (#2370) Rename invalid rpki finding to expired (#2377) Convert `docker-compose` to `docker compose` (#2341) Remove uWSGI (#2366) Prevent double github actions (#2374) Fix WEASYPRINT_BASEURL default value and change ports in docker-compose.yml (#2373) Remove debian11 packages (#2358) Error handling for Generate Report (#2274) Update dependencies (#2348) Add token authentication (#2349) Adds CAA records to the model, boefje, normalizer, adds a check bit and a finding (#2315) Check for sudo in install and update script (#2360) Feat/normalizer mimetype upload deeplink (#2220) Add hrefs to Basic Security overview (#2330) Render dicts and list ooi attrs as jsonfield (#2355)
Changes
This code adds error handling in the following two situations while generating a report:
Issue link
Closes #1972
Note: Only the first two errors of issue #1972 have been solved with this PR. Error 3 and 4 couldn't be reproduced, so they've been ignored for now.
Extra info
I've added a try-except in generate_report.py in the "generate_reports_for_oois" method. If an error occurs while trying to get the OOI data, the failed OOI will be saved in "error_oois". This way, the loop can continue to get the other OOIs (which are not failing).
After that, an error will be shown to the user with the failed OOI and the date. The report will still be generated with the succesfully obtained data from the other OOIs.
I've also added a try-except in base.py in the "get_oois" method, so the other error (that occured after changing the URL into a non-existing OOI) would be handled as well. All OOIs that do not fail, will be returned, so the report can still be generated.
Demo
Wrong date:
Wrong OOI:
Wrong date and OOI:
Code Checklist
Communication
.env
changes files if required and changed the.env-dist
accordingly.Checklist for code reviewers:
Copy-paste the checklist from the docs/source/templates folder into your comment.
Checklist for QA:
Copy-paste the checklist from the docs/source/templates folder into your comment.