Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: use match case for draft variable serialization (#36716)

ZHOU ZHICHENb2710b875b9b
diff --git a/api/controllers/console/app/workflow_draft_variable.py b/api/controllers/console/app/workflow_draft_variable.py
index 83f0d1dde6b..5aa243597a7 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)