Skip to content

Commit

Permalink
Merge pull request #15690 from CartoDB/jgoizueta/fix-conn-metadata
Browse files Browse the repository at this point in the history
Fix small issues in connector metadata endpoints
  • Loading branch information
jgoizueta authored Jun 5, 2020
2 parents 81ad2ff + 495a338 commit a11e1fd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Development
- Increase limit of certificates for SQL direct from 3 to 5 ([#2536](https://github.com/CartoDB/support/issues/2536))

### Bug fixes / enhancements
- Fix missing connector metadata error information ([#15690](https://github.com/CartoDB/cartodb/pull/15690))
- Add maxRetries for aws s3 operation to improve reliability ([#15679](https://github.com/CartoDB/cartodb/pull/15679))
- Add metrics for connectors actions ([#155564](https://github.com/CartoDB/cartodb/pull/15564))
- Make DB Direct server_ca configurable ([#15650](https://github.com/CartoDB/cartodb/pull/15650))
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/carto/api/connectors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def projects
render_jsonp({ errors: e.message }, 501)
rescue Carto::Connector::InvalidParametersError => e
render_jsonp({ errors: e.message }, 422)
rescue
rescue => e
render_jsonp({ errors: "Error connecting to provider #{provider_id}: #{e}" }, 400)
end
end
Expand Down Expand Up @@ -118,7 +118,7 @@ def project_dataset_tables
rescue Carto::Connector::InvalidParametersError => e
render_jsonp({ errors: e.message }, 422)
rescue => e
render_jsonp({ errors: "Error connecting to provider #{provider_id}, #{e}" }, 400)
render_jsonp({ errors: "Error connecting to provider #{provider_id}: #{e}" }, 400)
end
end

Expand Down
11 changes: 7 additions & 4 deletions lib/carto/connector/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def [](name)
v
end

def delete(name)
k, _v = fetch(name)
@params.delete(k)
end

def blank?
@params.blank?
end
Expand Down Expand Up @@ -97,6 +102,7 @@ def normalized_names
end

def normalize_parameter_names(names)
names ||= @accepted_parameters
normalized_array(Array(names))
end

Expand All @@ -105,10 +111,7 @@ def errors(only_for: nil, parameters_term: 'parameters')
if @accepted_parameters.present?
invalid_params = normalized_names - @accepted_parameters
missing_parameters = @required_parameters - normalized_names
if only_for.present?
only_for = normalize_parameter_names(only_for)
missing_parameters &= only_for
end
missing_parameters &= normalize_parameter_names(only_for)
if missing_parameters.present?
errors << "Missing required #{parameters_term} #{missing_parameters * ','}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/connectors_api.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace :cartodb do
Carto::ConnectorProvider.create! name: provider_name
end
end
providers = Carto::Connector.providers(all: true).keys.map { |name| "'#{name}'" }
providers = Carto::Connector.providers(all: true).keys
Carto::ConnectorProvider.where.not(name: providers).each do |provider|
puts "Provider #{provider.name} is not configured in the code!"
end
Expand Down

0 comments on commit a11e1fd

Please sign in to comment.