[Backend] Fix - Task V2 conversion changes to make new proxy city/state feature work (#4153)

This commit is contained in:
Marc Kelechava
2025-12-01 16:08:36 -08:00
committed by GitHub
parent 342629002a
commit acce1c869d
3 changed files with 54 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ from skyvern.forge.sdk.db.models import (
ScriptModel,
StepModel,
TaskModel,
TaskV2Model,
WorkflowModel,
WorkflowParameterModel,
WorkflowRunBlockModel,
@@ -36,6 +37,7 @@ from skyvern.forge.sdk.schemas.organizations import (
Organization,
OrganizationAuthToken,
)
from skyvern.forge.sdk.schemas.task_v2 import TaskV2
from skyvern.forge.sdk.schemas.tasks import Task, TaskStatus
from skyvern.forge.sdk.schemas.workflow_runs import WorkflowRunBlock
from skyvern.forge.sdk.workflow.models.parameter import (
@@ -204,6 +206,15 @@ def convert_to_task(task_obj: TaskModel, debug_enabled: bool = False, workflow_p
return task
def convert_to_task_v2(task_v2_model: TaskV2Model, debug_enabled: bool = False) -> TaskV2:
if debug_enabled:
LOG.debug("Converting TaskV2Model to TaskV2", observer_cruise_id=task_v2_model.observer_cruise_id)
task_v2_data = {column.name: getattr(task_v2_model, column.name) for column in TaskV2Model.__table__.columns}
# Deserialize proxy_location FIRST (string → GeoTarget), otherwise model_validate will fail for city/state proxy selections
task_v2_data["proxy_location"] = _deserialize_proxy_location(task_v2_model.proxy_location)
return TaskV2.model_validate(task_v2_data)
def convert_to_step(step_model: StepModel, debug_enabled: bool = False) -> Step:
if debug_enabled:
LOG.debug("Converting StepModel to Step", step_id=step_model.step_id)