Skip to content

Commit

Permalink
declare artifact_content variable to avoid reference before assignmen…
Browse files Browse the repository at this point in the history
…t in case of exception (#1554)

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`
  • Loading branch information
sa3eed3ed authored Sep 26, 2024
1 parent b31ee07 commit 338f28b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions turbinia/workers/analysis/llm_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 338f28b

Please sign in to comment.