Skip to content

Commit

Permalink
fix: handle nil response when determining webhook success status
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 18, 2021
1 parent 601387b commit 20ca9e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/pact_broker/webhooks/webhook_execution_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/pact_broker/webhooks/webhook_request_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 20ca9e6

Please sign in to comment.