A platform for community discussion. Free, open, simple.
FIX: Keep workflow templates on the latest node versions (#45385)
Régis Hanol2d63b92ac6b3
diff --git a/.skills/discourse-workflow-nodes/SKILL.md b/.skills/discourse-workflow-nodes/SKILL.mdindex e90d28459d5..60ba3fad362 100644--- a/.skills/discourse-workflow-nodes/SKILL.md+++ b/.skills/discourse-workflow-nodes/SKILL.md@@ -55,6 +55,7 @@ Renaming or removing an output key, or changing its meaning, breaks saved workfl- Services resolve the saved version with `NodeData.node_type(node)`, never a hard-coded `V1`.- Deprecated versions keep running for saved workflows, are hidden from the palette and AI catalog, and show an editor notice with an Upgrade action. Remove them after a deprecation window.- Spec both: `match_node_output_schema(Foo::V1)` pins the old keys, `match_node_output_schema(Foo::V2)` the new ones. `node_deprecation_spec` checks `superseded_by`.+- Bump the node in `config/templates/*.json`, migrate its parameters, and check downstream expressions; `workflow_templates_spec` enforces the version and parameter names.## Output conventionsdiff --git a/plugins/discourse-workflows/config/templates/auto-tag-topics.json b/plugins/discourse-workflows/config/templates/auto-tag-topics.jsonindex eabfaa43ce9..11634131853 100644--- a/plugins/discourse-workflows/config/templates/auto-tag-topics.json+++ b/plugins/discourse-workflows/config/templates/auto-tag-topics.json@@ -45,7 +45,7 @@{"id": "topic-tags","type": "action:topic_tags",- "typeVersion": "1.0",+ "typeVersion": "2.0","name": "Topic tags","parameters": {"topic_id": "={{ $json.topic.id }} "diff --git a/plugins/discourse-workflows/spec/integration/workflow_templates_spec.rb b/plugins/discourse-workflows/spec/integration/workflow_templates_spec.rbnew file mode 100644index 00000000000..b5b90abf054--- /dev/null+++ b/plugins/discourse-workflows/spec/integration/workflow_templates_spec.rb@@ -0,0 +1,25 @@+# frozen_string_literal: true++RSpec.describe "Workflow templates" do+ it "uses the latest version of every node and only its declared parameters" do+ Dir[File.join(DiscourseWorkflows::TEMPLATES_PATH, "*.json")].each do |path|+ JSON.parse(File.read(path))["nodes"].each do |node|+ label = "#{File.basename(path)} #{node["id"]} (#{node["type"]})"+ latest_version =+ DiscourseWorkflows::Registry.latest_version(node["type"], include_disabled_plugins: true)++ expect(node["typeVersion"]).to eq(latest_version), "#{label}: bump to #{latest_version}"++ node_type =+ DiscourseWorkflows::Registry.find_node_type(+ node["type"],+ version: latest_version,+ include_disabled_plugins: true,+ )+ undeclared = node["parameters"].keys - node_type.properties.keys.map(&:to_s)++ expect(undeclared).to be_empty, "#{label}: #{undeclared} not declared by #{latest_version}"+ end+ end+ end+end