voxpupuli / puppet-archive

Compressed archive file download and extraction with native types/providers for Windows and Unix
https://forge.puppet.com/puppet/archive
Apache License 2.0
59 stars 176 forks source link

weird issue with the proxy settings if 'proxy_server' seems to be set not fully correct #506

Open merclangrat opened 9 months ago

merclangrat commented 9 months ago

We use archive module in our setup and we found a weird issue: puppet was failing with the error Error: Failed to apply catalog: undefined method `to_sym' for nil:NilClass in the following line https://github.com/voxpupuli/puppet-archive/blob/7c9734e3457982b3aa64c3f647a722e87d1b0ad1/lib/puppet/type/archive.rb#L278

That looked weird. On some our servers we have proxy but on other ones we don't, there proxy_server was set to undef, but, as I understand, Ruby considered that it's not empty and tried to use URI.scheme (which returned "nil" and then failed)

I tried different approaches and had to hack the code to make it working, checking not self[:proxy_server] in Line 277 but URI(self[:proxy_server]).scheme

Can you please have a look into this issue? I am not familiar with Ruby and that was the easiest approach I could find. Maybe, if proxy_server is not empty but doesn't have a scheme (e.g. proxy.example.com:3128, not http://proxy.example.com:3128, the module would consider http as a default scheme?