task v2 support jinja style (#1978)

This commit is contained in:
Shuchang Zheng 2025-03-20 11:03:39 -07:00 committed by GitHub
parent b90ae3b30c
commit ea906e2f7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2229,6 +2229,22 @@ class TaskV2Block(Block):
) -> list[PARAMETER_TYPE]:
return []
def format_potential_template_parameters(self, workflow_run_context: WorkflowRunContext) -> None:
self.prompt = self.format_block_parameter_template_from_workflow_run_context(self.prompt, workflow_run_context)
if self.url:
self.url = self.format_block_parameter_template_from_workflow_run_context(self.url, workflow_run_context)
if self.totp_identifier:
self.totp_identifier = self.format_block_parameter_template_from_workflow_run_context(
self.totp_identifier, workflow_run_context
)
if self.totp_verification_url:
self.totp_verification_url = self.format_block_parameter_template_from_workflow_run_context(
self.totp_verification_url, workflow_run_context
)
self.totp_verification_url = prepend_scheme_and_validate_url(self.totp_verification_url)
async def execute(
self,
workflow_run_id: str,
@ -2240,6 +2256,19 @@ class TaskV2Block(Block):
from skyvern.forge.sdk.services import task_v2_service
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRunStatus
workflow_run_context = self.get_workflow_run_context(workflow_run_id)
try:
self.format_potential_template_parameters(workflow_run_context)
except Exception as e:
return await self.build_block_result(
success=False,
failure_reason=f"Failed to format jinja template: {str(e)}",
output_parameter_value=None,
status=BlockStatus.failed,
workflow_run_block_id=workflow_run_block_id,
organization_id=organization_id,
)
if not self.url:
browser_state = app.BROWSER_MANAGER.get_for_workflow_run(workflow_run_id)
if browser_state: