theforeman / foreman_rh_cloud

a plugin to Foreman that generates and uploads reports to the Red Hat cloud
GNU General Public License v3.0
6 stars 30 forks source link

SAT-25518 - Change removed URI.escape to CGI.escape w Ruby3 #887

Closed chris1984 closed 3 months ago

chris1984 commented 3 months ago

With the switch to Ruby3 we are getting the following traceback with inventory sync:

13:07:08 rails.1   | 2024-06-13T13:07:08 [W|bac|9b31bf0e] undefined method `encode' for URI:Module (NoMethodError)
13:07:08 rails.1   |  9b31bf0e | /home/vagrant/foreman_rh_cloud/lib/foreman_inventory_upload.rb:78:in `inventory_export_url'
13:07:08 rails.1   |  9b31bf0e | /home/vagrant/foreman_rh_cloud/lib/inventory_sync/async/query_inventory_job.rb:74:in `request_url'
13:07:08 rails.1   |  9b31bf0e | /home/vagrant/foreman_rh_cloud/lib/inventory_sync/async/query_inventory_job.rb:57:in `query_inventory'

According to Stack Overflow Ruby3 got rid of URI.escape and suggest using CGI.escape https://stackoverflow.com/questions/68635238/undefined-method-encode-for-urimodule-with-gem-rspotify https://stackoverflow.com/questions/68174351/undefined-method-escape-for-urimodule

After PR, sync runs fine.

I looked in the code and this was the only instance I could find of URI.escape