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: ignore empty string in 'config_route' #614

Merged
merged 1 commit into from
Aug 17, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Airbrake Ruby Changelog

### master

* Remote config: fixed bug where remote config cannot be applied when the remote
config's `config_route` is an empty string
([#614](https://github.com/airbrake/airbrake-ruby/pull/614))

### [v5.0.0][v5.0.0] (August 17, 2020)

Breaking changes:
Expand Down
7 changes: 4 additions & 3 deletions lib/airbrake-ruby/remote_settings/settings_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,18 @@ def interval
# @param [String] remote_config_host
# @return [String] where the config is stored on S3.
def config_route(remote_config_host)
if [email protected]?('config_route') || !@data['config_route']
if @data.key?('config_route') &&
@data['config_route'] && !@data['config_route'].empty?
return format(
CONFIG_ROUTE_PATTERN,
host: remote_config_host.chomp('/'),
host: @data['config_route'].chomp('/'),
project_id: @project_id,
)
end

format(
CONFIG_ROUTE_PATTERN,
host: @data['config_route'].chomp('/'),
host: remote_config_host.chomp('/'),
project_id: @project_id,
)
end
Expand Down
15 changes: 14 additions & 1 deletion spec/remote_settings/settings_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
context "and when the remote host doesn't with a slash" do
let(:host) { 'http://example.com' }

it "returns the route with the host" do
it "returns the route with the given host" do
expect(described_class.new(project_id, {}).config_route(host)).to eq(
"http://example.com/2020-06-18/config/#{project_id}/config.json",
)
Expand All @@ -122,6 +122,19 @@
)
end
end

context "when the given remote host in the remote config is an empty string" do
let(:data) do
{ 'config_route' => '' }
end

it "returns the route with the default instead" do
expect(described_class.new(project_id, data).config_route(host)).to eq(
'https://v1-production-notifier-configs.s3.amazonaws.com/' \
"2020-06-18/config/#{project_id}/config.json",
)
end
end
end

describe "#error_notifications?" do
Expand Down