Skip to content

Commit

Permalink
Merge pull request #3289 from huginn/fix_parse_body_validation
Browse files Browse the repository at this point in the history
Fix the validation for parse_body
  • Loading branch information
knu committed Jul 4, 2023
2 parents 61be669 + 265525a commit cc1f8c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/agents/post_agent.rb
Expand Up @@ -144,7 +144,7 @@ def validate_options
errors.add(:base, "if provided, output_mode must be 'clean' or 'merge'")
end

if options['parse_body'].present? && /\A(?:true|false)\z|\{/.match?(options['parse_body'].to_s)
if options['parse_body'].present? && !/\A(?:true|false)\z|\{/.match?(options['parse_body'].to_s)
errors.add(:base, "if provided, parse_body must be 'true' or 'false'")
end

Expand Down
1 change: 1 addition & 0 deletions spec/models/agents/post_agent_spec.rb
Expand Up @@ -303,6 +303,7 @@

it "emits the parsed JSON body when parse_body is true" do
@checker.options['parse_body'] = 'true'
@checker.save!
@checker.check
expect(@checker.events.last.payload['body']).to eq json_data
end
Expand Down

0 comments on commit cc1f8c7

Please sign in to comment.