tryvium-travels/memongo

Can't start memmongo with replicaset - panic with wrong error returned

shlomi-dr opened this issue · 0 comments

When trying to start mongo with a replica set, we are getting a panic instead of an error due to:

memongo/memongo.go

Lines 176 to 181 in a32a48f

err2 := replicaSetCommand.Run()
if err2 != nil {
logger.Warnf("Error initiating replica: %v", err2)
return nil, err
}

Where err is erroneously returned instead of err2.

But the actual problem lies a few lines above, where the existence of mongo cli tools is assumed to exist on the $PATH:

memongo/memongo.go

Lines 167 to 171 in a32a48f

if opts.ShouldUseReplica {
//nolint:gosec
mongoCommand := fmt.Sprintf("mongo --port %d --retryWrites --eval \"rs.initiate()\"", opts.Port)
//nolint:gosec
replicaSetCommand := exec.Command("bash", "-c", mongoCommand)