mu-semtech / mu-ruby-template

Template for running Ruby/Sinatra microservices
MIT License
3 stars 10 forks source link

name conflict #16

Open nathanielrb opened 5 years ago

nathanielrb commented 5 years ago

I found this while trying to use the Faraday http gem, and I'm not sure if the problem is Faraday's or the template's. (My Ruby knowledge isn't that deep.)

The query defined in the included SinatraTemplate::Utils gets mixed up with a query used in Faraday's internal definitions (https://github.com/lostisland/faraday/blob/88de44ebe3c40f9050553ce7c0018990b92c2f38/lib/faraday/request.rb#L48-L62)

Any ideas?

Example web.rb:

require 'faraday'

get "/faraday" do
  response = Faraday.get 'http://redpencil.io'
  log.info response
  "it worked"
end
nvdk commented 4 years ago

after some research, this is indeed a bug in the template. This has been around for quite some time and should indeed be addressed. Because we include the utils in a top level file all these functions become global. We should address it by including the utils inside the helpers. that way they are still available in web.rb as helpers and can be used as utils were necessary.

my main fear is that some services may depend on this (faulty) behavior where our helpers are global functions.

erikap commented 11 months ago

Since v2.14.0 the template has a flag USE_LEGACY_UTILS to disable the inclusion of the utility functions as globals. By setting USE_LEGACY_UTILS to false you can avoid the conflict on query with the Faraday gem.