From 20ca9e6621bc2959bc850d98b45341246a2c708e Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 18 Feb 2021 18:41:20 +1100 Subject: [PATCH] fix: handle nil response when determining webhook success status --- lib/pact_broker/webhooks/webhook_execution_result.rb | 4 +++- lib/pact_broker/webhooks/webhook_request_logger.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pact_broker/webhooks/webhook_execution_result.rb b/lib/pact_broker/webhooks/webhook_execution_result.rb index 1adbaaa6b..d2893dcb2 100644 --- a/lib/pact_broker/webhooks/webhook_execution_result.rb +++ b/lib/pact_broker/webhooks/webhook_execution_result.rb @@ -14,9 +14,11 @@ def initialize(request, response, logs, error = nil) end def success? - unless response.nil? + if response # Response HTTP Code must be in success list otherwise it is false PactBroker.configuration.webhook_http_code_success.include? response.code.to_i + else + false end end end diff --git a/lib/pact_broker/webhooks/webhook_request_logger.rb b/lib/pact_broker/webhooks/webhook_request_logger.rb index aac320f69..08ee26613 100644 --- a/lib/pact_broker/webhooks/webhook_request_logger.rb +++ b/lib/pact_broker/webhooks/webhook_request_logger.rb @@ -117,9 +117,11 @@ def log_error uuid, e, base_url end def success?(response) - unless response.nil? + if response # Response HTTP Code must be in success list otherwise it is false PactBroker.configuration.webhook_http_code_success.include? response.code.to_i + else + false end end