From b2710b875b9b40bb739055a33c0e6fdbf3b49366 Mon Sep 17 00:00:00 2001 From: ZHOU ZHICHEN <118870511+zhuiguangzhe2003@users.noreply.github.com> Date: Wed, 27 May 2026 17:59:28 +0800 Subject: [PATCH] refactor: use match case for draft variable serialization (#36716) Co-authored-by: unknown Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../console/app/workflow_draft_variable.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/api/controllers/console/app/workflow_draft_variable.py b/api/controllers/console/app/workflow_draft_variable.py index 83f0d1dde6..5aa243597a 100644 --- a/api/controllers/console/app/workflow_draft_variable.py +++ b/api/controllers/console/app/workflow_draft_variable.py @@ -83,13 +83,14 @@ def _serialize_var_value(variable: WorkflowDraftVariable): # create a copy of the value to avoid affecting the model cache. value = value.model_copy(deep=True) # Refresh the url signature before returning it to client. - if isinstance(value, FileSegment): - file = value.value - file.remote_url = file.generate_url() - elif isinstance(value, ArrayFileSegment): - files = value.value - for file in files: + match value: + case FileSegment(): + file = value.value file.remote_url = file.generate_url() + case ArrayFileSegment(): + files = value.value + for file in files: + file.remote_url = file.generate_url() return _convert_values_to_json_serializable_object(value)