Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-9319): browser error message improvement (#5717)
Shuchang Zhengb72b0d535144
diff --git a/skyvern/exceptions.py b/skyvern/exceptions.pyindex eefcb560e..a0593eb05 100644--- a/skyvern/exceptions.py+++ b/skyvern/exceptions.py@@ -377,6 +377,15 @@ class UnknownErrorWhileCreatingBrowserContext(SkyvernException):trimmed_message = trimmed_message.split("Browser logs:")[0].strip()normalized_message = " ".join(trimmed_message.split())+ if (+ "launch_persistent_context" in normalized_message+ and "target page, context or browser has been closed" in normalized_message.lower()+ ):+ return (+ "The browser closed unexpectedly during launch. This is usually transient. "+ f"{UnknownErrorWhileCreatingBrowserContext.SUPPORT_GUIDANCE}"+ )+timeout_match = re.search(r"Timeout\s+(\d+)ms\s+exceeded", normalized_message, flags=re.IGNORECASE)if timeout_match and "launch_persistent_context" in normalized_message:timeout_seconds = int(timeout_match.group(1)) // 1000diff --git a/tests/unit/test_exception_messages.py b/tests/unit/test_exception_messages.pyindex c14ca3776..56cec69f8 100644--- a/tests/unit/test_exception_messages.py+++ b/tests/unit/test_exception_messages.py@@ -124,7 +124,9 @@ def test_unknown_error_strips_browser_logs_with_internal_path() -> None:assert "/opt/internal-browser" not in messageassert "Browser logs:" not in messageassert "--disable-field-trial-config" not in message- assert "Target page, context or browser has been closed" in message+ # SKY-9319: TargetClosedError-style failures now return a friendly retry message+ # instead of the raw Playwright string.+ assert "The browser closed unexpectedly during launch" in messageassert "[email protected]" in message