Skip to content

Commit

Permalink
handle better empty tag overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Oct 29, 2024
1 parent 94cf018 commit 8b2c63f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
11 changes: 1 addition & 10 deletions backend/windmill-common/src/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")]
Expand All @@ -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>>,
Expand Down
5 changes: 5 additions & 0 deletions backend/windmill-worker/src/worker_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/ModulePreview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
Expand Down

0 comments on commit 8b2c63f

Please sign in to comment.