Browser Profile CDP Fix (#3990)
This commit is contained in:
@@ -100,8 +100,11 @@ class BrowserProfilesClient:
|
|||||||
client = Skyvern(
|
client = Skyvern(
|
||||||
api_key="YOUR_API_KEY",
|
api_key="YOUR_API_KEY",
|
||||||
)
|
)
|
||||||
|
session = client.browser_sessions.create_browser_session()
|
||||||
|
client.browser_sessions.close_browser_session(session.browser_session_id)
|
||||||
client.browser_profiles.create_browser_profile(
|
client.browser_profiles.create_browser_profile(
|
||||||
name="name",
|
name="name",
|
||||||
|
browser_session_id=session.browser_session_id,
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
_response = self._raw_client.create_browser_profile(
|
_response = self._raw_client.create_browser_profile(
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ async def _create_profile_from_session(
|
|||||||
description: str | None,
|
description: str | None,
|
||||||
browser_session_id: str,
|
browser_session_id: str,
|
||||||
) -> BrowserProfile:
|
) -> BrowserProfile:
|
||||||
browser_state = await app.PERSISTENT_SESSIONS_MANAGER.get_browser_state(browser_session_id, organization_id)
|
browser_session = await app.DATABASE.get_persistent_browser_session(browser_session_id, organization_id)
|
||||||
if browser_state is None:
|
if browser_session is None:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Browser session not found for profile creation",
|
"Browser session not found for profile creation",
|
||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
@@ -236,16 +236,22 @@ async def _create_profile_from_session(
|
|||||||
)
|
)
|
||||||
raise BrowserSessionNotFound(browser_session_id)
|
raise BrowserSessionNotFound(browser_session_id)
|
||||||
|
|
||||||
session_dir = browser_state.browser_artifacts.browser_session_dir
|
session_dir = await app.STORAGE.retrieve_browser_profile(
|
||||||
|
organization_id=organization_id,
|
||||||
|
profile_id=browser_session_id,
|
||||||
|
)
|
||||||
if not session_dir:
|
if not session_dir:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Browser session has no persisted data",
|
"Browser session archive not found for profile creation",
|
||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
browser_session_id=browser_session_id,
|
browser_session_id=browser_session_id,
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
detail="Browser session does not have persisted data to store",
|
detail=(
|
||||||
|
"Browser session does not have a persisted profile archive. "
|
||||||
|
"Close the session and wait for upload before creating a browser profile."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user