validate browser session id when running tasks or workflows (#2874)
Some checks failed
Run tests and pre-commit / Frontend Lint and Build (push) Has been cancelled
Publish Fern Docs / run (push) Has been cancelled
Run tests and pre-commit / Run tests and pre-commit hooks (push) Has been cancelled

This commit is contained in:
Shuchang Zheng 2025-07-04 01:49:51 -07:00 committed by GitHub
parent 133cee4358
commit f832206f38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View file

@ -10,6 +10,7 @@ from skyvern import analytics
from skyvern.config import settings
from skyvern.constants import GET_DOWNLOADED_FILES_TIMEOUT, SAVE_DOWNLOADED_FILES_TIMEOUT
from skyvern.exceptions import (
BrowserSessionNotFound,
FailedToSendWebhook,
InvalidCredentialId,
MissingValueForParameter,
@ -779,6 +780,15 @@ class WorkflowService:
organization_id: str,
parent_workflow_run_id: str | None = None,
) -> WorkflowRun:
# validate the browser session id
if workflow_request.browser_session_id:
browser_session = await app.DATABASE.get_persistent_browser_session(
session_id=workflow_request.browser_session_id,
organization_id=organization_id,
)
if not browser_session:
raise BrowserSessionNotFound(browser_session_id=workflow_request.browser_session_id)
return await app.DATABASE.create_workflow_run(
workflow_permanent_id=workflow_permanent_id,
workflow_id=workflow_id,