v 0.14.2 failing to start with git output
Hi together, I upgraded from 0.13.2 to 0.14.2 today and found an issue, that oxidized is crashing - probably because of some error:
Puma 2.16.0 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://127.0.0.1:8888
wrong argument type nil (expected String)
/home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:176:in `new': wrong argument type nil (expected String) (TypeError)
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:176:in `update'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:57:in `store'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:43:in `process'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `block in work'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `each'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `work'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:35:in `run'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:28:in `initialize'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:4:in `new'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:4:in `new'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/cli.rb:12:in `run'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/bin/oxidized:9:in `<top (required)>'
from /home/oxidized/bin/oxidized:23:in `load'
from /home/oxidized/bin/oxidized:23:in `<main>'
My output configuration looks like this:
[...]
output:
default: git
git:
user: oxidized
email: [email protected]
repo: /home/oxidized/net-config.git/
[...]
When falling back to 0.13.2 it works again. Is there any new parameter added I forget to set?
Are you using groups? Could you try to quote your repo? repo: "/home/oxidized/net-config.git/"
@ytti Yes I am using groups.
output:
default: git
git:
user: "oxidized"
email: "[email protected]"
repo: "/home/oxidized/net-config.git/"
I quoted it, but it is still failing with the same error.
For debugging could you add below this line: https://github.com/ytti/oxidized/blob/master/lib/oxidized/output/git.rb#L160
p repo
p file
p @opt[:group]
and show me the output, we should know what those variables are when the method is being called.
I did so, this is the output:
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://127.0.0.1:8888
"/home/oxidized/net-config.git"
"n343"
"group-n343"
wrong argument type nil (expected String)
/home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:179:in `new': wrong argument type nil (expected String) (TypeError)
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:179:in `update'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/output/git.rb:57:in `store'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:43:in `process'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `block in work'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `each'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/worker.rb:14:in `work'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:35:in `run'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:28:in `initialize'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:4:in `new'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/core.rb:4:in `new'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/lib/oxidized/cli.rb:12:in `run'
from /home/oxidized/.gem/ruby/gems/oxidized-0.14.2/bin/oxidized:9:in `<top (required)>'
from /home/oxidized/bin/oxidized:23:in `load'
from /home/oxidized/bin/oxidized:23:in `<main>'
n343 is my hostname, group-n343 is the groupname
I am confused. Somehow
if @opt[:group]
if @cfg.single_repo?
file = File.join @opt[:group], file
else
repo = if repo.is_a?(String)
File.join File.dirname(repo), @opt[:group] + '.git'
else
repo[@opt[:group]]
end
end
end
begin
repo = Rugged::Repository.new repo
...
Your repo turns nil there. Do you have single_repo set, it seems no. It seems almost as if if repo.is_a?(String) is not true, but I cannot imagine why it wouldn't be.
Can you help bit more, and tell us which branch the code is taking. Like add puts 'here' after the `ìf repo.is_a?(String)that is the branch it should take, but I suspect for some reason it takes theelse`` branch.
I'm having the same issue. I have single_repo set to no. Rolling back to 0.14.1 seems to fix it. The Git repo is in quotes.
It seems for some reason is if repo.is_a?(String)is potentially failing. And I think I think I just figured out why. Can you change Stringto ::String in the comparison and tell me if it works?
Looks like that fixed it.
if @opt[:group]
if @cfg.single_repo?
file = File.join @opt[:group], file
else
repo = if repo.is_a?(::String)
File.join File.dirname(repo), @opt[:group] + '.git'
else
repo[@opt[:group]]
end
end
end
...
I'll release new version soon.
Strange, didn't have this issue while developing this. :confused:
Which version o ruby are you using @network-guy ?
Why would any ruby version end up using ::String when under Oxidized there is String as well? Of course not terribly good practice to use core classes names, and in this case there isn't even any benefit, users aren't saying 'String' ever, so we could just as well call it OxidizedString and it'll probably be much cleaner that way.
so we could just as well call it OxidizedString and it'll probably be much cleaner that way.
I need to take another look in the Oxidized::String class, but can't we just monkey patch the String class to avoid this kind of problem?
We could monkey patch String and in case of Oxidized probably not have any ill-effect, it's not like anyone requires Oxidized as library. But there is no real need, because users aren't creating strings, they're getting them handed to them, so we can really handle them any instance, of any object, might as well be OxidizedString.
But I guess users often lose the Oxidized::String when their methods return String. With monkey-patching or refinements we could ensure that it'll always carry our convenient methods.
With monkey-patching or refinements we could ensure that it'll always carry our convenient methods.
yeah, that's what I was thinking. :smile: