optimize secrete value input (#4457)
This commit is contained in:
@@ -923,3 +923,10 @@ class PDFParsingError(SkyvernException):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
f"Failed to parse PDF '{file_identifier}'. pypdf error: {pypdf_error}; pdfplumber error: {pdfplumber_error}"
|
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"
|
||||||
|
)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from skyvern.exceptions import (
|
|||||||
AzureConfigurationError,
|
AzureConfigurationError,
|
||||||
BitwardenBaseError,
|
BitwardenBaseError,
|
||||||
CredentialParameterNotFoundError,
|
CredentialParameterNotFoundError,
|
||||||
|
ImaginarySecretValue,
|
||||||
SkyvernException,
|
SkyvernException,
|
||||||
WorkflowRunContextNotInitialized,
|
WorkflowRunContextNotInitialized,
|
||||||
)
|
)
|
||||||
@@ -52,6 +53,8 @@ BlockMetadata = dict[str, str | int | float | bool | dict | list | None]
|
|||||||
|
|
||||||
jinja_sandbox_env = SandboxedEnvironment()
|
jinja_sandbox_env = SandboxedEnvironment()
|
||||||
|
|
||||||
|
RANDOM_SECRET_ID_PREFIX = "placeholder_"
|
||||||
|
|
||||||
|
|
||||||
class WorkflowRunContext:
|
class WorkflowRunContext:
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -243,8 +246,15 @@ class WorkflowRunContext:
|
|||||||
assume it's an actual parameter value and return it.
|
assume it's an actual parameter value and return it.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if len(self.secrets) == 0:
|
||||||
|
return None
|
||||||
if isinstance(secret_id_or_value, str):
|
if 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 None
|
return None
|
||||||
|
|
||||||
def mask_secrets_in_data(self, data: Any, mask: str = "*****") -> Any:
|
def mask_secrets_in_data(self, data: Any, mask: str = "*****") -> Any:
|
||||||
@@ -292,7 +302,7 @@ class WorkflowRunContext:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_random_secret_id() -> str:
|
def 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]:
|
async def _get_credential_vault_and_item_ids(self, credential_id: str) -> tuple[str, str]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ from skyvern.exceptions import (
|
|||||||
FailToSelectByValue,
|
FailToSelectByValue,
|
||||||
IllegitComplete,
|
IllegitComplete,
|
||||||
ImaginaryFileUrl,
|
ImaginaryFileUrl,
|
||||||
|
ImaginarySecretValue,
|
||||||
InputToInvisibleElement,
|
InputToInvisibleElement,
|
||||||
InputToReadonlyElement,
|
InputToReadonlyElement,
|
||||||
InteractWithDisabledElement,
|
InteractWithDisabledElement,
|
||||||
@@ -595,6 +596,9 @@ class ActionHandler:
|
|||||||
except LLMProviderError as e:
|
except LLMProviderError as e:
|
||||||
LOG.exception("LLM error in action handler", action=action, exc_info=True)
|
LOG.exception("LLM error in action handler", action=action, exc_info=True)
|
||||||
actions_result.append(ActionFailure(e))
|
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:
|
except Exception as e:
|
||||||
LOG.exception("Unhandled exception in action handler", action=action)
|
LOG.exception("Unhandled exception in action handler", action=action)
|
||||||
actions_result.append(ActionFailure(e))
|
actions_result.append(ActionFailure(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user