Compare commits

...

5 Commits

Author SHA1 Message Date
HugoCasa
4e07fe2cc7 better fix 2025-10-16 15:15:37 +02:00
HugoCasa
d72e118dbe Revert "fix"
This reverts commit f83556bfb5.
2025-10-16 15:12:08 +02:00
HugoCasa
f83556bfb5 fix 2025-10-16 13:55:39 +02:00
HugoCasa
2731e7410a Merge remote-tracking branch 'origin/main' into hc/new-flow-node-min-version 2025-10-16 11:30:01 +02:00
HugoCasa
1bbdefd0cc fix(backend): only apply new flow node format on latest version 2025-10-16 11:29:52 +02:00
3 changed files with 27 additions and 31 deletions

View File

@@ -15,6 +15,7 @@ use crate::{
scripts::{ScriptHash, ScriptLang},
};
use anyhow::anyhow;
use serde_json::value::to_raw_value;
#[cfg(feature = "scoped_cache")]
use std::thread::ThreadId;
@@ -287,20 +288,17 @@ pub struct FlowData {
impl FlowData {
pub fn from_raw(raw_flow: Box<RawValue>) -> error::Result<Self> {
let (flow, summary) = if let Ok(parsed) =
serde_json::from_str::<crate::flows::FlowNodeFlow>(raw_flow.get())
{
(parsed.value, parsed.summary)
if let Ok(parsed) = serde_json::from_str::<crate::flows::FlowNodeFlow>(raw_flow.get()) {
// only save the value part in the raw flow
let raw_flow = to_raw_value(&parsed.value)?;
Ok(Self { raw_flow, flow: parsed.value, summary: parsed.summary })
} else {
// fallback to plain FlowValue
(
serde_json::from_str::<FlowValue>(raw_flow.get()).map_err(|e| {
error::Error::internal_err(format!("Failed to parse as FlowValue: {}", e))
})?,
None,
)
};
Ok(Self { raw_flow, flow, summary })
let value = serde_json::from_str::<FlowValue>(raw_flow.get()).map_err(|e| {
error::Error::internal_err(format!("Failed to parse as FlowValue: {}", e))
})?;
Ok(Self { raw_flow, flow: value, summary: None })
}
}
pub fn value(&self) -> &FlowValue {

View File

@@ -254,6 +254,7 @@ lazy_static::lazy_static! {
pub static ref MIN_VERSION_IS_AT_LEAST_1_427: Arc<RwLock<bool>> = Arc::new(RwLock::new(false));
pub static ref MIN_VERSION_IS_AT_LEAST_1_432: Arc<RwLock<bool>> = Arc::new(RwLock::new(false));
pub static ref MIN_VERSION_IS_AT_LEAST_1_440: Arc<RwLock<bool>> = Arc::new(RwLock::new(false));
pub static ref MIN_VERSION_IS_AT_LEAST_1_560: Arc<RwLock<bool>> = Arc::new(RwLock::new(false));
// Features flags:
pub static ref DISABLE_FLOW_SCRIPT: bool = std::env::var("DISABLE_FLOW_SCRIPT").ok().is_some_and(|x| x == "1" || x == "true");
@@ -1069,6 +1070,7 @@ pub async fn update_min_version(conn: &Connection) -> bool {
*MIN_VERSION_IS_AT_LEAST_1_427.write().await = min_version >= Version::new(1, 427, 0);
*MIN_VERSION_IS_AT_LEAST_1_432.write().await = min_version >= Version::new(1, 432, 0);
*MIN_VERSION_IS_AT_LEAST_1_440.write().await = min_version >= Version::new(1, 440, 0);
*MIN_VERSION_IS_AT_LEAST_1_560.write().await = min_version >= Version::new(1, 560, 0);
*MIN_VERSION.write().await = min_version.clone();
min_version >= cur_version

View File

@@ -22,7 +22,9 @@ use windmill_common::jobs::JobPayload;
use windmill_common::scripts::{hash_script, NewScript, ScriptHash};
#[cfg(feature = "python")]
use windmill_common::worker::PythonAnnotations;
use windmill_common::worker::{to_raw_value, to_raw_value_owned, write_file, Connection};
use windmill_common::worker::{
to_raw_value, to_raw_value_owned, write_file, Connection, MIN_VERSION_IS_AT_LEAST_1_560,
};
#[cfg(feature = "python")]
use windmill_parser_yaml::AnsibleRequirements;
@@ -1655,27 +1657,21 @@ async fn insert_flow_modules<'c>(
return Ok(tx);
}
let flow_node_flow = FlowNodeFlow {
value: FlowValue {
modules: std::mem::take(modules),
failure_module: failure_module.cloned(),
same_worker,
..Default::default()
},
summary,
let flow_value = FlowValue {
modules: std::mem::take(modules),
failure_module: failure_module.cloned(),
same_worker,
..Default::default()
};
let flow = if *MIN_VERSION_IS_AT_LEAST_1_560.read().await {
to_raw_value(&FlowNodeFlow { value: flow_value, summary })
} else {
to_raw_value(&flow_value)
};
let id;
(tx, id) = insert_flow_node(
tx,
path,
workspace_id,
None,
None,
Some(&Json(to_raw_value(&flow_node_flow))),
None,
)
.await?;
(tx, id) =
insert_flow_node(tx, path, workspace_id, None, None, Some(&Json(flow)), None).await?;
*modules_node = Some(id);
Ok(tx)
}