Goose panic

Issue #29 resolved
Brendan Fosberry created an issue

I get a panic when running this from a docker container:

root@359dc6646327:/# DB_HOST=127.0.0.1 DB_PORT=1234 DB_USER=me DB_PASSWORD=abc DB_NAME=test goose --env=default up
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x4ab345]

goroutine 1 [running]:
runtime.panic(0x6f7fc0, 0xc4d168)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
bitbucket.org/liamstask/goose/lib/goose.funcĀ·003(0xc21004bb70, 0xd, 0x0, 0x0, 0x7fa9e3584670, ...)
    /go/src/bitbucket.org/liamstask/goose/lib/goose/migrate.go:322 +0x35
path/filepath.Walk(0xc21004bb70, 0xd, 0x7fa9e33e4d60, 0x74e7a0, 0x2)
    /usr/local/go/src/pkg/path/filepath/path.go:378 +0x81
bitbucket.org/liamstask/goose/lib/goose.GetMostRecentDBVersion(0xc21004bb70, 0xd, 0xffffffffffffffff, 0x0, 0x0)
    /go/src/bitbucket.org/liamstask/goose/lib/goose/migrate.go:331 +0x85
main.upRun(0xc4b940, 0xc21000a030, 0x0, 0x0)
    /go/src/bitbucket.org/liamstask/goose/cmd/goose/cmd_up.go:23 +0xf0
main.(*Command).Exec(0xc4b940, 0xc21000a030, 0x0, 0x0)
    /go/src/bitbucket.org/liamstask/goose/cmd/goose/cmd.go:26 +0x93
main.main()
    /go/src/bitbucket.org/liamstask/goose/cmd/goose/main.go:56 +0x342
root@359dc6646327:/# go version
go version go1.2.2 linux/amd64
root@359dc6646327:/# cat ./db/dbconf.yml 
default:
    driver: postgres
    open: host=$DB_HOST port=$DB_PORT user=$DB_USER password="$DB_PASSWORD" dbname=$DB_NAME sslmode=disable

Comments (2)

  1. Brendan Fosberry reporter

    Probably related to this, walkerr is not being caught:

    / helper to identify the most recent possible version
    // within a folder of migration scripts
    func GetMostRecentDBVersion(dirpath string) (version int64, err error) {
    
        version = -1
    
        filepath.Walk(dirpath, func(name string, info os.FileInfo, walkerr error) error {
    
            if !info.IsDir() {
                if v, e := NumericComponent(name); e == nil {
                    if v > version {
                        version = v
                    }
                }
            }
    
            return nil
        })
    
        if version == -1 {
            err = errors.New("no valid version found")
        }
    
        return
    }
    
  2. Log in to comment