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

remote_settings: log HTML responses as errors #627

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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