From d1189485d9c64fca7901a51ec85358e482420154 Mon Sep 17 00:00:00 2001 From: Zac Blazic Date: Wed, 8 Jul 2020 19:36:27 +0200 Subject: [PATCH] Raise generic error if parsed response is a string It's currently possible for the parsed response to be a string instead of a hash in some cases. One scenario is if the server returns a 504 gateway timeout, in which case we are returned a string of HTML instead of JSON response. --- lib/onelogin/api/cursor.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/onelogin/api/cursor.rb b/lib/onelogin/api/cursor.rb index 0b5d248..bc63ad6 100644 --- a/lib/onelogin/api/cursor.rb +++ b/lib/onelogin/api/cursor.rb @@ -66,6 +66,8 @@ def fetch_next_page if json.nil? raise OneLogin::Api::ApiException.new("Response could not be parsed", 500) + elsif json.is_a?(String) + raise OneLogin::Api::ApiException.new(response.message, response.code) elsif !json.has_key?(@container) && json.has_key?('status') && json["status"]["error"] == true raise OneLogin::Api::ApiException.new(extract_error_message_from_response(response), json["status"]["code"]) elsif !json.has_key?(@container) && json.has_key?('statusCode')