Skip to content

Automate browser based workflows with AI

fix(SKY-10453): handle nullable download field in action parsing (#6255)

LawyZhengef13e49718ff
diff --git a/skyvern/webeye/actions/parse_actions.py b/skyvern/webeye/actions/parse_actions.py
index 883d3d351..94d12fd87 100644
--- a/skyvern/webeye/actions/parse_actions.py
+++ b/skyvern/webeye/actions/parse_actions.py
@@ -149,7 +149,7 @@ def parse_action(
return ClickAction(
**base_action_dict,
file_url=file_url,
- download=action.get("download", False),
+ download=action.get("download") or False,
click_context=click_context,
repeat=2 if double_click else 1,
)
@@ -200,7 +200,7 @@ def parse_action(
index=index,
),
input_or_select_context=input_or_select_context,
- download=action.get("download", False),
+ download=action.get("download") or False,
)
if action_type == ActionType.CHECKBOX:
diff --git a/tests/unit/test_actions.py b/tests/unit/test_actions.py
index dacb0002f..81aa1f062 100644
--- a/tests/unit/test_actions.py
+++ b/tests/unit/test_actions.py
@@ -3,7 +3,14 @@ from unittest.mock import MagicMock
import pytest
from pydantic import ValidationError
-from skyvern.webeye.actions.actions import Action, ClickAction, KeypressAction, NullAction, WebAction
+from skyvern.webeye.actions.actions import (
+ Action,
+ ClickAction,
+ KeypressAction,
+ NullAction,
+ SelectOptionAction,
+ WebAction,
+)
from skyvern.webeye.actions.parse_actions import parse_action
@@ -168,3 +175,53 @@ def test_parse_click_no_double_click_field() -> None:
)
assert isinstance(action, ClickAction)
assert action.repeat == 1
+
+
[email protected]("download_value", [None, False, True])
+def test_parse_select_option_download_field(download_value: bool | None) -> None:
+ """SELECT_OPTION must parse successfully even when LLM returns download: null (SKY-10453)."""
+ action = parse_action(
+ action={
+ "action_type": "SELECT_OPTION",
+ "id": "1",
+ "reasoning": "test",
+ "download": download_value,
+ "option": {"label": "Yes", "index": 1, "value": "Yes"},
+ },
+ scraped_page=_mock_scraped_page(),
+ )
+ assert isinstance(action, SelectOptionAction)
+ expected = download_value if download_value is not None else False
+ assert action.download is expected
+
+
+def test_parse_select_option_download_missing() -> None:
+ """SELECT_OPTION with no download key should default to False."""
+ action = parse_action(
+ action={
+ "action_type": "SELECT_OPTION",
+ "id": "1",
+ "reasoning": "test",
+ "option": {"label": "No", "index": 2, "value": "No"},
+ },
+ scraped_page=_mock_scraped_page(),
+ )
+ assert isinstance(action, SelectOptionAction)
+ assert action.download is False
+
+
[email protected]("download_value", [None, False, True])
+def test_parse_click_download_field(download_value: bool | None) -> None:
+ """CLICK must parse successfully even when LLM returns download: null (SKY-10453)."""
+ action = parse_action(
+ action={
+ "action_type": "CLICK",
+ "id": "1",
+ "reasoning": "test",
+ "download": download_value,
+ },
+ scraped_page=_mock_scraped_page(),
+ )
+ assert isinstance(action, ClickAction)
+ expected = download_value if download_value is not None else False
+ assert action.download is expected