jackc / tern

The SQL Fan's Migrator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

runtime error: invalid memory address or nil pointer dereference

ceastman-r7 opened this issue · comments

I am getting the following stack trace from this section of code:

migrationRoot, _ := fs.Sub(migrationFiles, "/workspace/db/tern")

err = migrator.LoadMigrations(migrationRoot)

trace:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x563c653e5c27]

goroutine 1 [running]:
io/fs.ReadDir({0x0, 0x0}, {0x563c65b95510, 0x1})
io/fs/readdir.go:33 +0x87
io/fs.glob({0x0?, 0x0?}, {0x563c65b95510, 0x1}, {0xc0001ce100, 0x1}, {0x0, 0x0, 0x0})
io/fs/glob.go:101 +0x67
io/fs.globWithLimit({0x0, 0x0}, {0xc0001ce100, 0x1}, 0x1)
io/fs/glob.go:63 +0x2ea
io/fs.globWithLimit({0x0, 0x0}, {0xc0001ce100, 0x7}, 0x0)
io/fs/glob.go:72 +0x288
io/fs.Glob(...)
io/fs/glob.go:34
github.com/jackc/tern/v2/migrate.(*Migrator).LoadMigrations(0xc0005183c0, {0x0?, 0x0})
github.com/jackc/tern/v2@v2.1.1/migrate/migrate.go:160 +0x488
main.NewMigrator({0xc000552090?, 0x563c665633c0?})

I verified in the container that there are tern migration sql files:

ck-55655549c4-vlbrr:/workspace/db/tern$ ls -al
total 8
drwxr-sr-x 2 1001 cnb 68 Jan 1 1980 .
drwxr-sr-x 3 1001 cnb 18 Jan 1 1980 ..
-rw-r--r-- 1 1001 cnb 3962 Jan 1 1980 001_v1_initial.up.sql
-rw-r--r-- 1 1001 cnb 3069 Jan 1 1980 002_v1_schema_data.up.sql

missing the go embed comment

i.e.
//go:embed data/*.sql