handle better empty tag overrides

This commit is contained in:
Ruben Fiszel
2024-10-29 08:57:16 +01:00
parent 94cf0184a8
commit a32a0abd3f
3 changed files with 7 additions and 11 deletions
+1 -10
View File
@@ -424,7 +424,7 @@ pub enum FlowModuleValue {
path: String,
#[serde(skip_serializing_if = "Option::is_none")]
hash: Option<ScriptHash>,
#[serde(deserialize_with = "empty_string_as_none")]
#[serde(skip_serializing_if = "Option::is_none")]
tag_override: Option<String>,
},
Flow {
@@ -482,14 +482,6 @@ fn is_none_or_empty(expr: &Option<String>) -> bool {
expr.is_none() || expr.as_ref().unwrap().is_empty()
}
fn empty_string_as_none<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
where
D: serde::Deserializer<'de>,
{
let s: Option<String> = Option::deserialize(deserializer)?;
Ok(s.filter(|s| !s.is_empty()))
}
#[derive(Deserialize)]
struct UntaggedFlowModuleValue {
#[serde(rename = "type")]
@@ -498,7 +490,6 @@ struct UntaggedFlowModuleValue {
input_transforms: Option<HashMap<String, InputTransform>>,
path: Option<String>,
hash: Option<ScriptHash>,
#[serde(deserialize_with = "empty_string_as_none")]
tag_override: Option<String>,
iterator: Option<InputTransform>,
modules: Option<Vec<FlowModule>>,
@@ -3761,6 +3761,11 @@ async fn script_to_payload(
module: &FlowModule,
tag_override: &Option<String>,
) -> Result<JobPayloadWithTag, Error> {
let tag_override = if tag_override.as_ref().is_some_and(|x| x.trim().is_empty()) {
None
} else {
tag_override.clone()
};
let (payload, tag, delete_after_use, script_timeout) = if script_hash.is_none() {
let (jp, tag, delete_after_use, script_timeout) =
script_path_to_payload(script_path, db, &flow_job.workspace_id, Some(true)).await?;
@@ -75,7 +75,7 @@
script.content,
script.language,
args,
$flowStore?.tag ?? val.tag_override ?? script.tag
$flowStore?.tag ?? (val.tag_override ? val.tag_override : script.tag)
)
} else if (val.type == 'flow') {
await testJobLoader?.abstractRun(() =>