From bd597fff0c1234c07f9a38a2086021802169964b Mon Sep 17 00:00:00 2001 From: Said Eid <46205691+sa3eed3ed@users.noreply.github.com> Date: Thu, 26 Sep 2024 01:06:19 +0200 Subject: [PATCH] declare artifact_content variable to avoid reference before assignment in case of exception in case the content is not UTF-8 encoded an exception will be raised and artifact_content will never be assigned, this cause the task to fail with a misleading exception: `[local variable 'artifact_content' referenced before assignment]`, while it should be `Artifact {evidence.artifact_name} has empty content or not UTF-8 encoded` --- turbinia/workers/analysis/llm_analyzer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/turbinia/workers/analysis/llm_analyzer.py b/turbinia/workers/analysis/llm_analyzer.py index 6f6af7fdf..dbe6821eb 100644 --- a/turbinia/workers/analysis/llm_analyzer.py +++ b/turbinia/workers/analysis/llm_analyzer.py @@ -105,6 +105,7 @@ def run(self, evidence, result): open_function = gzip.open # Read the input file + artifact_content = None try: with open_function(evidence.local_path, "rb") as input_file: artifact_content = input_file.read().decode("utf-8")