Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
optimize secrete value input (#4457)
LawyZheng55c71e7e3e5c
diff --git a/skyvern/exceptions.py b/skyvern/exceptions.pyindex 58b9220fe..193ae8172 100644--- a/skyvern/exceptions.py+++ b/skyvern/exceptions.py@@ -923,3 +923,10 @@ class PDFParsingError(SkyvernException):super().__init__(f"Failed to parse PDF '{file_identifier}'. pypdf error: {pypdf_error}; pdfplumber error: {pdfplumber_error}")+++class ImaginarySecretValue(SkyvernException):+ def __init__(self, value: str) -> None:+ super().__init__(+ f"The value {value} is imaginary. Try to double-check to see if this value is included in the provided information"+ )diff --git a/skyvern/forge/sdk/workflow/context_manager.py b/skyvern/forge/sdk/workflow/context_manager.pyindex da9755f51..56c8e97f2 100644--- a/skyvern/forge/sdk/workflow/context_manager.py+++ b/skyvern/forge/sdk/workflow/context_manager.py@@ -11,6 +11,7 @@ from skyvern.exceptions import (AzureConfigurationError,BitwardenBaseError,CredentialParameterNotFoundError,+ ImaginarySecretValue,SkyvernException,WorkflowRunContextNotInitialized,)@@ -52,6 +53,8 @@ BlockMetadata = dict[str, str | int | float | bool | dict | list | None]jinja_sandbox_env = SandboxedEnvironment()+RANDOM_SECRET_ID_PREFIX = "placeholder_"+class WorkflowRunContext:@classmethod@@ -243,8 +246,15 @@ class WorkflowRunContext:assume it's an actual parameter value and return it."""+ if len(self.secrets) == 0:+ return Noneif isinstance(secret_id_or_value, str):- return self.secrets.get(secret_id_or_value)+ if secret_id_or_value.startswith(RANDOM_SECRET_ID_PREFIX):+ if secret_id_or_value not in self.secrets:+ raise ImaginarySecretValue(secret_id_or_value)+ return self.secrets[secret_id_or_value]+ else:+ return self.secrets.get(secret_id_or_value)return Nonedef mask_secrets_in_data(self, data: Any, mask: str = "*****") -> Any:@@ -292,7 +302,7 @@ class WorkflowRunContext:@staticmethoddef generate_random_secret_id() -> str:- return f"placeholder_{generate_random_string()}"+ return f"{RANDOM_SECRET_ID_PREFIX}{generate_random_string(length=4)}"async def _get_credential_vault_and_item_ids(self, credential_id: str) -> tuple[str, str]:"""diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex 88aad5ebd..aefd19901 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -39,6 +39,7 @@ from skyvern.exceptions import (FailToSelectByValue,IllegitComplete,ImaginaryFileUrl,+ ImaginarySecretValue,InputToInvisibleElement,InputToReadonlyElement,InteractWithDisabledElement,@@ -595,6 +596,9 @@ class ActionHandler:except LLMProviderError as e:LOG.exception("LLM error in action handler", action=action, exc_info=True)actions_result.append(ActionFailure(e))+ except ImaginarySecretValue as e:+ LOG.exception("Imaginary secret value", action=action, exc_info=True)+ actions_result.append(ActionFailure(e))except Exception as e:LOG.exception("Unhandled exception in action handler", action=action)actions_result.append(ActionFailure(e))