Skip to content

Commit

Permalink
Fix: avoid exception on broken tree, reduce logging on known broken t…
Browse files Browse the repository at this point in the history
…rees
  • Loading branch information
Rafiot committed Feb 16, 2025
1 parent 8e79c9d commit 1a3611f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lookyloo/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ def index_capture(self, uuid_to_index: str, directory: Path) -> None:

except (TreeNeedsRebuild, NoValidHarFile) as e:
self.logger.warning(f'Error loading the pickle for {uuid_to_index}: {e}')
except AttributeError as e:
# Happens when indexing the IPs, they were a list, and are now dict.
# Skip from the the warning logs.
self.logger.info(f'Error during indexing for {uuid_to_index}, recreate pickle: {e}')
remove_pickle_tree(directory)
except Exception as e:
self.logger.error(f'Error during indexing for {uuid_to_index}, recreate pickle: {e}')
remove_pickle_tree(directory)
Expand Down
8 changes: 7 additions & 1 deletion website/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,13 @@ def urlnode_urls_in_rendered_content(tree_uuid: str, node_uuid: str) -> Response
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/rendered_content', methods=['GET'])
@file_response # type: ignore[misc]
def urlnode_rendered_content(tree_uuid: str, node_uuid: str) -> Response | None:
urlnode = lookyloo.get_urlnode_from_tree(tree_uuid, node_uuid)
try:
urlnode = lookyloo.get_urlnode_from_tree(tree_uuid, node_uuid)
except IndexError:
to_send = b"Unable to find rendered content, the tree seem to be broken. Please reload the page and try again."
lookyloo.remove_pickle(tree_uuid)
return send_file(BytesIO(to_send), mimetype='text/plain',
as_attachment=True, download_name='rendered_content.txt')
if not urlnode.rendered_html:
return None
return send_file(BytesIO(urlnode.rendered_html.getvalue()), mimetype='text/plain',
Expand Down

0 comments on commit 1a3611f

Please sign in to comment.