From e96d7253a24af86934ab647e1c354d4c39299be2 Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:55:24 +0800 Subject: [PATCH] fix(flow): fix autofill type parse --- middleware/flow/src/serv/flow_inst_serv.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/middleware/flow/src/serv/flow_inst_serv.rs b/middleware/flow/src/serv/flow_inst_serv.rs index aef711934..2584d9818 100644 --- a/middleware/flow/src/serv/flow_inst_serv.rs +++ b/middleware/flow/src/serv/flow_inst_serv.rs @@ -1041,12 +1041,20 @@ impl FlowInstServ { Value::String("".to_string()) } } - crate::dto::flow_var_dto::DefaultValueType::AutoFill => match FillType::from_str(&default.value.to_string()).map_err(|err| { - funs.err().internal_error("flow_inst", "check_transfer_vars", &err.to_string(), "400-flow-inst-vars-field-missing") - })? { - FillType::Time => Value::String(Utc::now().timestamp_millis().to_string()), - FillType::Person => Value::String(ctx.owner.clone()), - }, + crate::dto::flow_var_dto::DefaultValueType::AutoFill => { + match FillType::from_str(&default.value.as_str().ok_or(funs.err().bad_request( + "flow_transitions", + "default_value_type_parse", + "AutoFill default value type is not string", + "400-flow-inst-vars-field-missing", + ))?) + .map_err(|err| { + funs.err().internal_error("flow_transitions", "default_value_type_parse", &err.to_string(), "400-flow-inst-vars-field-missing") + })? { + FillType::Time => Value::String(Utc::now().timestamp_millis().to_string()), + FillType::Person => Value::String(ctx.owner.clone()), + } + } }; var.dyn_default_value = Some(default_value); };