diff --git a/app/models/agents/post_agent.rb b/app/models/agents/post_agent.rb index 5f13bd48d5..7182107a3f 100644 --- a/app/models/agents/post_agent.rb +++ b/app/models/agents/post_agent.rb @@ -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 diff --git a/spec/models/agents/post_agent_spec.rb b/spec/models/agents/post_agent_spec.rb index e98b9702ef..40951e09cf 100644 --- a/spec/models/agents/post_agent_spec.rb +++ b/spec/models/agents/post_agent_spec.rb @@ -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