Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil response from RestClient causes 'undefined method `code' for nil:NilClass' #13

Open
deepanshumarwah opened this issue Apr 28, 2021 · 0 comments

Comments

@deepanshumarwah
Copy link

deepanshumarwah commented Apr 28, 2021

res = RestClient.post( uri, body, headers)
res
rescue => e
c = e.response.code.to_i
if c == 429 || c == 500 || c==503
if retries < @max_retries
retries += 1
sleep(@retry_sleep_period)
retry
end
end
raise e
end
end

res can be nil here, leading to a scenario where the following is logged from the logstash-output-azure_loganalytics plugin when Azure::Loganalytics::Datacollectorapi::Client.is_success(res) is called and is_success attempts to evaluate res.code
from logstash:

[ERROR][logstash.outputs.azureloganalytics][pipeline-common][pipeline_common_output_azure_log_analytics_ingest] Exception occured in posting to DataCollector API as log type ExampleLogType: 'undefined method `code' for nil:NilClass', data=>[{"original_timestamp":"2021-04-15T10:36:21.315Z","event_uuid":"ede25ed2-0d3e-4898-8c5d-3...

There appears to be a related issue logged at rest-client/rest-client#655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant