Skip to content

Commit

Permalink
remote_settings: log HTML responses as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo committed Nov 12, 2020
1 parent 2d284be commit 76041b4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Airbrake Ruby Changelog

### master

* Remote config: improved handling of responses that return HTML (they will be
logged correctly) ([#627](https://github.com/airbrake/airbrake-ruby/pull/627))

### [v5.1.0][v5.1.0] (October 20, 2020)

* Deleted support for dumping/loading the remote config
Expand Down
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/remote_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def fetch_config

# AWS S3 API returns XML when request is not valid. In this case we just
# print the returned body and exit the method.
if response.start_with?('<?xml ')
if response.start_with?('<?xml ') || response.start_with?('<html>')
logger.error(response)
return {}
end
Expand Down
19 changes: 19 additions & 0 deletions spec/remote_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@
end
end

context "when API returns an HTML response" do
let!(:stub) do
stub_request(:get, Regexp.new(endpoint))
.to_return(status: 200, body: '<html>...')
end

it "doesn't update settings data" do
settings = nil
remote_settings = described_class.poll(project_id, host) do |data|
settings = data
end
sleep(0.1)
remote_settings.stop_polling

expect(stub).to have_been_requested.once
expect(settings.interval).to eq(600)
end
end

context "when a config route is specified in the returned data" do
let(:new_config_route) do
'213/config/111/config.json'
Expand Down

0 comments on commit 76041b4

Please sign in to comment.