From fa1afd6a6df1b7538e75f6622c1a680f4e630e61 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Wed, 28 Jan 2026 00:39:35 -0600 Subject: [PATCH] fix(backend): replace assert with ValueError in FileReadBlock Asserts can be stripped with -O flag. Use explicit ValueError for graph_exec_id validation to ensure consistent error handling. Co-Authored-By: Claude Opus 4.5 --- autogpt_platform/backend/backend/blocks/text.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/text.py b/autogpt_platform/backend/backend/blocks/text.py index 07807adb16..359e22a84f 100644 --- a/autogpt_platform/backend/backend/blocks/text.py +++ b/autogpt_platform/backend/backend/blocks/text.py @@ -454,9 +454,12 @@ class FileReadBlock(Block): return_format="for_local_processing", ) - # Get full file path - assert execution_context.graph_exec_id # Validated by store_media_file - file_path = get_exec_file_path(execution_context.graph_exec_id, stored_file_path) + # Get full file path (graph_exec_id validated by store_media_file above) + if not execution_context.graph_exec_id: + raise ValueError("execution_context.graph_exec_id is required") + file_path = get_exec_file_path( + execution_context.graph_exec_id, stored_file_path + ) if not Path(file_path).exists(): raise ValueError(f"File does not exist: {file_path}")