From 5a03fd718353c5b09745a8885eee8c5855d9c15e Mon Sep 17 00:00:00 2001 From: Vincent Pochet Date: Mon, 14 Oct 2024 17:58:36 +0200 Subject: [PATCH] fix(integration): Fix rate limit handling (#2686) ## Context This PR follows https://github.com/getlago/lago-api/pull/2570 ## Description It updates the way we check for the presence of the rate error limit code in the payload to avoid parsing the JSON body and be independent from the format of the response. --- app/services/integrations/aggregator/base_service.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/services/integrations/aggregator/base_service.rb b/app/services/integrations/aggregator/base_service.rb index ea96d34c300..fca83c4a0e4 100644 --- a/app/services/integrations/aggregator/base_service.rb +++ b/app/services/integrations/aggregator/base_service.rb @@ -123,9 +123,7 @@ def message(error) def request_limit_error?(http_error) return false unless http_error.error_code.to_i == 500 - http_error.json_message.dig('error', 'payload', 'error', 'code') == REQUEST_LIMIT_ERROR_CODE - rescue JSON::ParserError - false + http_error.error_body.include?(REQUEST_LIMIT_ERROR_CODE) end end end