From eddafea48015246a655d85188719fa3ec4428064 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Sat, 1 Aug 2020 23:18:19 +0000 Subject: [PATCH] don't crash on naive (parameter-less) HTTP request This fix is ported in from sgx-catapult, where we made the fix in https://gitlab.com/ossguy/sgx-catapult/commit/300def9 - it is fairly simple, but also fairly important. Here is the description: Without this fix, one will get the following error (and subsequent crash) if the port that sgx-catapult is running on receives a naive HTTP request, such as a "GET /" (from Wget or curl or similar): Shutting down gateway due to exception 013: no implicit conversion of nil into String --- sgx-bwmsgsv2.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index ab1fa1300c36c4f99d7ae06180c9eb520d026a55..fb6fe7840eb4cdd8d0af4d136c5d6e85c005dcf1 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -812,6 +812,11 @@ class WebhookHandler < Goliath::API puts 'ENV: ' + env.reject{ |k| k == 'params' }.to_s + if params.empty? + puts 'PARAMS empty!' + return [200, {}, "OK"] + end + # TODO: process each message in list, not just first one jparams = params['_json'][0]['message']