diff --git a/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb b/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb index 590d23e..3341bb1 100644 --- a/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb +++ b/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb @@ -18,9 +18,24 @@ def sync next if filename.start_with?(".") || !filename.end_with?(".asl") payload = worktree.read_file(filename) - found = current.delete(filename) || self.class.module_parent::Workflow.new(:configuration_script_source_id => id) - - found.update!(:name => filename, :manager_id => manager_id, :payload => payload, :payload_type => "json") + payload_valid, payload_error = + begin + Floe::Workflow.new(payload) + true + rescue Floe::InvalidWorkflowError => err + [false, err.message] + end + + found = current.delete(filename) || self.class.module_parent::Workflow.new(:configuration_script_source_id => id) + + found.update!( + :name => filename, + :manager_id => manager_id, + :payload => payload, + :payload_type => "json", + :payload_valid => payload_valid, + :payload_error => payload_error + ) end end