Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Stop the PBS worker run-error test turning a slow run into TimeoutError (SKY-18760) (#8986)
Shuchang Zheng3dcc56776733
diff --git a/skyvern/forge/taskv3/field_commit.py b/skyvern/forge/taskv3/field_commit.pyindex 6814d501a..68c26fb32 100644--- a/skyvern/forge/taskv3/field_commit.py+++ b/skyvern/forge/taskv3/field_commit.py@@ -150,7 +150,8 @@ _PHONE_MIN_DIGITS = 8def _phone_digits(text: str) -> str | None:- return re.sub(r"\D", "", text) if _PHONE_RE.fullmatch(text.strip()) else None+ folded = _fold(text)+ return re.sub(r"\D", "", folded) if _PHONE_RE.fullmatch(folded.strip()) else Nonedef _plus_added(typed: str, held: str) -> bool:@@ -158,8 +159,8 @@ def _plus_added(typed: str, held: str) -> bool:return (digits is not Noneand len(digits) >= _PHONE_MIN_DIGITS- and not typed.strip().startswith("+")- and held.strip().startswith("+")+ and not _fold(typed).strip().startswith("+")+ and _fold(held).strip().startswith("+")and _phone_digits(held) == digits)diff --git a/tests/unit/test_taskv3_field_commit.py b/tests/unit/test_taskv3_field_commit.pyindex 14f01caee..935782e7f 100644--- a/tests/unit/test_taskv3_field_commit.py+++ b/tests/unit/test_taskv3_field_commit.py@@ -122,9 +122,14 @@ def test_compare_text_never_accepts_extra_or_missing_alphanumerics() -> None:("(555) 000-1234", "+5 550001234", EntryMatch.PLUS_ADDED),("(555) 000-1234", "+(555) 000-1234", EntryMatch.PLUS_ADDED),("004455500012", "+004455500012", EntryMatch.PLUS_ADDED),+ # A field that groups digits with a no-break space.+ ("5550001234", "+55\u00a050001234", EntryMatch.PLUS_ADDED),+ ("5550001234", "+55\u202f50001234", EntryMatch.PLUS_ADDED),# The fix: the number retyped with its country code, regrouped by the field.("+1 5550001234", "+1 555 000 1234", EntryMatch.REFORMATTED),("+44 20 0000 1234", "+442000001234", EntryMatch.REFORMATTED),+ ("+1 5550001234", "+1\u00a0555\u00a0000\u00a01234", EntryMatch.REFORMATTED),+ ("\uff0b15551234567", "+1 (555) 123-4567", EntryMatch.REFORMATTED),# A decimal point still decides first, with "+" on both sides.("+15.00", "+1500", EntryMatch.DIFFERENT),("+1.5", "+15", EntryMatch.DIFFERENT),@@ -132,6 +137,7 @@ def test_compare_text_never_accepts_extra_or_missing_alphanumerics() -> None:("1500", "+1500", EntryMatch.DIFFERENT),# A country code the page added is not the same digits.("5550001234", "+1 555 000 1234", EntryMatch.DIFFERENT),+ ("5550001234", "+1\u00a0555\u00a0000\u00a01234", EntryMatch.DIFFERENT),# A mask placeholder is not a held value, with or without the picker's code left in it.("5550001234", "(___) ___-____", EntryMatch.NOT_HELD),("09/05/2026", "__/__/____", EntryMatch.NOT_HELD),diff --git a/tests/unit/test_taskv3_goal_check.py b/tests/unit/test_taskv3_goal_check.pyindex f0420ffb4..a99f842c9 100644--- a/tests/unit/test_taskv3_goal_check.py+++ b/tests/unit/test_taskv3_goal_check.py@@ -1186,3 +1186,57 @@ async def test_a_cancel_landing_while_only_the_premise_check_runs_leaves_the_verassert result.status == "ok" and result.data is not Noneassert result.data["status"] == ("completed" if converts else "terminated")assert checked == ["no PIN screen"]++[email protected]("reasks", [True, False])+async def test_a_cancel_raised_inside_the_premise_check_does_not_end_the_run(reasks: bool) -> None:+ async def premise(reason: str, prior_checks: int) -> None:+ raise asyncio.CancelledError++ finish = make_finish_tool(+ **_gate_kwargs(pending=False, blocked=False, unsettled=False),+ unlisted_reask=_ReaskSpy(converts=False) if reasks else None,+ terminate_premise=premise,+ )+ result = await finish.handler({"status": "terminated", "reason": "no PIN screen"})++ assert result.status == "ok" and result.data is not None+ assert result.data["status"] == "terminated"+++async def test_the_runs_own_cancel_still_ends_the_run_while_the_premise_check_runs() -> None:+ started = asyncio.Event()++ async def premise(reason: str, prior_checks: int) -> None:+ started.set()+ await asyncio.Event().wait()++ finish = make_finish_tool(+ **_gate_kwargs(pending=False, blocked=False, unsettled=False),+ terminate_premise=premise,+ )+ run = asyncio.ensure_future(finish.handler({"status": "terminated", "reason": "no PIN screen"}))+ await started.wait()+ run.cancel()++ with pytest.raises(asyncio.CancelledError):+ await run+++async def test_each_terminate_tells_the_premise_check_how_many_came_before() -> None:+ seen: list[int] = []++ async def premise(reason: str, prior_checks: int) -> None:+ seen.append(prior_checks)++ finish = make_finish_tool(+ **_gate_kwargs(pending=False, blocked=False, unsettled=False),+ terminate_premise=premise,+ )+ for _ in range(2):+ await finish.handler({"status": "terminated", "reason": "no PIN screen"})++ assert seen == [0, 1]