Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Stop reporting browser-extension clipboard refusals as frontend errors (SKY-13996) (#8196)
Aaron Perez357b92a1632b
diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex 1d904120a..de6ade496 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -106,7 +106,7 @@ from skyvern.forge.sdk.cache import extraction_cache, extraction_shadowfrom skyvern.forge.sdk.copilot.block_goal_wrapping import unwrap_goal_fieldsfrom skyvern.forge.sdk.core import skyvern_contextfrom skyvern.forge.sdk.core.hashing import diagnostic_fingerprint-from skyvern.forge.sdk.core.http_request_authorization import RedirectHopAuthorizer+from skyvern.forge.sdk.core.http_request_authorization import RedirectHopAuthorizer, deny_unenrolled_redirect_hopfrom skyvern.forge.sdk.core.skyvern_context import PendingFileChooserListener, ensure_contextfrom skyvern.forge.sdk.db.datetime_utils import naive_utc_nowfrom skyvern.forge.sdk.event.factory import EventStrategyFactory@@ -972,6 +972,8 @@ async def _close_eager_capture_then_teardown_retention(async def _adopted_session_download_binding(download: Download,active_page: Page,+ *,+ download_binding: DownloadBinding = DownloadBinding.RUN_DIR,) -> AsyncIterator[tuple[Any, "RedirectHopAuthorizer[GuardedFileFetchHopResult]", str | None]]:"""Lease the exact context binding that owns an adopted-session download."""download_page = download.page@@ -981,6 +983,14 @@ async def _adopted_session_download_binding(if download_context is not active_page.context:raise RuntimeError("Adopted-session download page context does not match the active page context")+ if download_binding == DownloadBinding.SESSION_DIR:+ # A provider-owned remote binding never has an interceptor to lease: the creator that stamps+ # SESSION_DIR binds none, and every download-dir rebind — the only other installer of the+ # ownership lock — is skipped for this binding. Its branches forbid URL replay anyway, so+ # deny the hop rather than yielding an authority nothing here can honour.+ yield None, deny_unenrolled_redirect_hop, None+ return+try:bind_lock = download_context._skyvern_cdp_download_interceptor_bind_lock # type: ignore[attr-defined]except AttributeError as exc:@@ -3948,13 +3958,19 @@ class ActionHandler:_remaining_download_wait_seconds(),))- async with _adopted_session_download_binding(captured_download, page) as (+ async with _adopted_session_download_binding(+ captured_download,+ page,+ download_binding=resolved_download_binding,+ ) as (download_interceptor,authorize_request_hop,download_scope,):- cookie_header = await download_interceptor._cookie_header_for_url(- captured_download.url+ cookie_header = (+ await download_interceptor._cookie_header_for_url(captured_download.url)+ if download_interceptor is not None+ else None)request_headers = {"Cookie": cookie_header} if cookie_header else {}saved_path = await _save_adopted_session_download(diff --git a/tests/unit/test_adopted_session_download_save.py b/tests/unit/test_adopted_session_download_save.pyindex 755b79970..15317e26e 100644--- a/tests/unit/test_adopted_session_download_save.py+++ b/tests/unit/test_adopted_session_download_save.py@@ -15,13 +15,17 @@ import base64from collections.abc import Awaitable, Callablefrom functools import partialfrom pathlib import Path+from types import SimpleNamespacefrom unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom structlog.testing import capture_logsfrom skyvern.forge.sdk.browser_network_egress_monitor import BrowserNetworkEgressMonitor-from skyvern.forge.sdk.core.http_request_authorization import RunScopedRedirectHopAuthorizer+from skyvern.forge.sdk.core.http_request_authorization import (+ RunScopedRedirectHopAuthorizer,+ deny_unenrolled_redirect_hop,+)from skyvern.webeye.actions.handler import (_adopted_session_download_binding,_EagerAdoptedBlobCapture,@@ -1024,6 +1028,39 @@ async def test_adopted_session_download_binding_blocks_scope_rotation_until_releassert interceptor.download_scope == "next_run"+async def test_adopted_session_download_binding_skips_the_lease_for_a_provider_owned_binding() -> None:+ """A provider-owned remote context carries neither the interceptor nor its ownership lock: the+ creator that stamps SESSION_DIR binds no interceptor, and every download-dir rebind skips it."""+ page = _page_with_refetch()+ page.context = SimpleNamespace()+ download = _download()+ download.page = page++ async with _adopted_session_download_binding(download, page, download_binding=DownloadBinding.SESSION_DIR) as (+ bound_interceptor,+ authorize_request_hop,+ download_scope,+ ):+ assert bound_interceptor is None+ assert authorize_request_hop is deny_unenrolled_redirect_hop+ assert download_scope is None+++async def test_adopted_session_download_binding_still_demands_the_lease_for_a_run_dir_binding() -> None:+ """The skip is scoped to the provider-owned binding; a run-dir context that lost its lock is+ still a real defect and must not be waved through."""+ page = _page_with_refetch()+ page.context = SimpleNamespace()+ download = _download()+ download.page = page++ with pytest.raises(RuntimeError, match="interceptor ownership lock"):+ async with _adopted_session_download_binding(download, page):+ pass++@pytest.mark.asyncioasync def test_rebind_rotates_download_authority(tmp_path, monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setattr(