Skip to content

Commit f982782

Browse files
committed
Fix useless factory call and add check for flows/update_service if invalid id is provided
1 parent dea02d3 commit f982782

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/services/namespaces/projects/flows/update_service.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ def update_nodes(t)
105105
delete_old_nodes(t, all_nodes.reject { |node| updated_nodes.pluck(:node).pluck(:id).include?(node.id) })
106106
end
107107

108-
def update_starting_node(_t, all_nodes)
108+
def update_starting_node(t, all_nodes)
109109
starting_node = all_nodes.find { |n| n[:input].id == flow_input.starting_node_id }
110110

111-
return nil if starting_node.nil?
111+
if starting_node.nil? && flow_input.starting_node_id.present?
112+
t.rollback_and_return! ServiceResponse.error(
113+
message: 'Starting node not found',
114+
error_code: :node_not_found
115+
)
116+
end
117+
return if starting_node.nil?
112118

113119
flow.starting_node = starting_node[:node]
114120
end

spec/factories/node_functions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
runtime_function factory: :runtime_function_definition
66
next_node { nil }
77
node_parameters { [] }
8-
flow factory: :flow
8+
flow
99
end
1010
end

0 commit comments

Comments
 (0)