From e729681f17670d009b298305ae9fb0149915b3a4 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Fri, 3 Oct 2025 17:18:30 -0700 Subject: [PATCH] sanitize python func names in script gen (#3611) --- skyvern/core/script_generations/generate_script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skyvern/core/script_generations/generate_script.py b/skyvern/core/script_generations/generate_script.py index ad220eb9..dd6cc886 100644 --- a/skyvern/core/script_generations/generate_script.py +++ b/skyvern/core/script_generations/generate_script.py @@ -440,7 +440,7 @@ def _action_to_stmt(act: dict[str, Any], task: dict[str, Any], assign_to_output: def _build_block_fn(block: dict[str, Any], actions: list[dict[str, Any]]) -> FunctionDef: - name = block.get("label") or _safe_name(block.get("title") or f"block_{block.get('workflow_run_block_id')}") + name = _safe_name(block.get("label") or block.get("title") or f"block_{block.get('workflow_run_block_id')}") body_stmts: list[cst.BaseStatement] = [] is_extraction_block = block.get("block_type") == "extraction" @@ -482,7 +482,7 @@ def _build_block_fn(block: dict[str, Any], actions: list[dict[str, Any]]) -> Fun def _build_task_v2_block_fn(block: dict[str, Any], child_blocks: list[dict[str, Any]]) -> FunctionDef: """Build a cached function for task_v2 blocks that calls child workflow sub-tasks.""" - name = block.get("label") or _safe_name(block.get("title") or f"block_{block.get('workflow_run_block_id')}") + name = _safe_name(block.get("label") or block.get("title") or f"block_{block.get('workflow_run_block_id')}") body_stmts: list[cst.BaseStatement] = [] # Add calls to child workflow sub-tasks