fix(backend): replace graph_exec_id or "" fallbacks with asserts

The empty string fallback was dead code since store_media_file() validates
graph_exec_id before these lines execute. Replace with explicit asserts
for clearer failure if assumptions are ever violated.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nicholas Tindle
2026-01-27 23:39:56 -06:00
parent 8f16d583a4
commit bae6be915f
3 changed files with 10 additions and 11 deletions

View File

@@ -121,9 +121,8 @@ async def create_mime_message(
execution_context=execution_context,
return_format="for_local_processing",
)
abs_path = get_exec_file_path(
execution_context.graph_exec_id or "", local_path
)
assert execution_context.graph_exec_id # Validated by store_media_file
abs_path = get_exec_file_path(execution_context.graph_exec_id, local_path)
part = MIMEBase("application", "octet-stream")
with open(abs_path, "rb") as f:
part.set_payload(f.read())
@@ -1191,7 +1190,8 @@ async def _build_reply_message(
execution_context=execution_context,
return_format="for_local_processing",
)
abs_path = get_exec_file_path(execution_context.graph_exec_id or "", local_path)
assert execution_context.graph_exec_id # Validated by store_media_file
abs_path = get_exec_file_path(execution_context.graph_exec_id, local_path)
part = MIMEBase("application", "octet-stream")
with open(abs_path, "rb") as f:
part.set_payload(f.read())
@@ -1721,9 +1721,8 @@ To: {original_to}
execution_context=execution_context,
return_format="for_local_processing",
)
abs_path = get_exec_file_path(
execution_context.graph_exec_id or "", local_path
)
assert execution_context.graph_exec_id # Validated by store_media_file
abs_path = get_exec_file_path(execution_context.graph_exec_id, local_path)
part = MIMEBase("application", "octet-stream")
with open(abs_path, "rb") as f:
part.set_payload(f.read())

View File

@@ -113,8 +113,9 @@ class ReadSpreadsheetBlock(Block):
)
# 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 or "", stored_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}")

View File

@@ -455,9 +455,8 @@ class FileReadBlock(Block):
)
# Get full file path
file_path = get_exec_file_path(
execution_context.graph_exec_id or "", stored_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)
if not Path(file_path).exists():
raise ValueError(f"File does not exist: {file_path}")