improve code block failure reason (#1910)
Co-authored-by: lawyzheng <lawyzheng1106@gmail.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
@@ -12,3 +12,6 @@ VITE_SKYVERN_API_KEY=YOUR_API_KEY
|
|||||||
|
|
||||||
# Enable recording skyvern logs as artifacts
|
# Enable recording skyvern logs as artifacts
|
||||||
VITE_ENABLE_LOG_ARTIFACTS=false
|
VITE_ENABLE_LOG_ARTIFACTS=false
|
||||||
|
|
||||||
|
# Enable code block node
|
||||||
|
VITE_ENABLE_CODE_BLOCK=false
|
||||||
|
|||||||
@@ -139,3 +139,10 @@ class InsecureCodeDetected(SkyvernException):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
f"Insecure code detected. Reason: {msg}",
|
f"Insecure code detected. Reason: {msg}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CustomizedCodeException(SkyvernException):
|
||||||
|
def __init__(self, exception: Exception) -> None:
|
||||||
|
super().__init__(
|
||||||
|
f"Failed to execute code block. Reason: {exception.__class__.__name__}: {str(exception)}",
|
||||||
|
)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ from skyvern.forge.sdk.schemas.task_v2 import TaskV2Status
|
|||||||
from skyvern.forge.sdk.schemas.tasks import Task, TaskOutput, TaskStatus
|
from skyvern.forge.sdk.schemas.tasks import Task, TaskOutput, TaskStatus
|
||||||
from skyvern.forge.sdk.workflow.context_manager import BlockMetadata, WorkflowRunContext
|
from skyvern.forge.sdk.workflow.context_manager import BlockMetadata, WorkflowRunContext
|
||||||
from skyvern.forge.sdk.workflow.exceptions import (
|
from skyvern.forge.sdk.workflow.exceptions import (
|
||||||
|
CustomizedCodeException,
|
||||||
FailedToFormatJinjaStyleParameter,
|
FailedToFormatJinjaStyleParameter,
|
||||||
InsecureCodeDetected,
|
InsecureCodeDetected,
|
||||||
InvalidEmailClientConfiguration,
|
InvalidEmailClientConfiguration,
|
||||||
@@ -1251,7 +1252,19 @@ async def wrapper():
|
|||||||
)
|
)
|
||||||
|
|
||||||
user_function = self.generate_async_user_function(self.code, page, parameter_values)
|
user_function = self.generate_async_user_function(self.code, page, parameter_values)
|
||||||
|
try:
|
||||||
result = await user_function()
|
result = await user_function()
|
||||||
|
except Exception as e:
|
||||||
|
exc = CustomizedCodeException(e)
|
||||||
|
return await self.build_block_result(
|
||||||
|
success=False,
|
||||||
|
failure_reason=exc.message,
|
||||||
|
output_parameter_value=None,
|
||||||
|
status=BlockStatus.failed,
|
||||||
|
workflow_run_block_id=workflow_run_block_id,
|
||||||
|
organization_id=organization_id,
|
||||||
|
)
|
||||||
|
|
||||||
result = json.loads(
|
result = json.loads(
|
||||||
json.dumps(result, default=lambda value: f"Object '{type(value)}' is not JSON serializable")
|
json.dumps(result, default=lambda value: f"Object '{type(value)}' is not JSON serializable")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user