Skip to content

Commit

Permalink
Check if a workflow payload is valid during sync
Browse files Browse the repository at this point in the history
When syncing a repository and creating workflows check if the payload is
valid and if it isn't set a (hopefully) helpful error message.
  • Loading branch information
agrare committed Nov 8, 2023
1 parent 2d88b90 commit a975aba
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a975aba

Please sign in to comment.