golang-migrate/migrate · error
no config
Error message
no config
What it means
ErrNilConfig is the redshift driver's sentinel returned by WithInstance and WithConnection when the supplied *Config is nil. Redshift is protocol-compatible with postgres and mirrors its driver structure, so it needs a non-nil config to read the migrations table and database name settings.
Source
Thrown at database/redshift/redshift.go:29
nurl "net/url"
"strconv"
"strings"
"sync/atomic"
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database"
"github.com/lib/pq"
)
func init() {
db := Redshift{}
database.Register("redshift", &db)
}
var DefaultMigrationsTable = "schema_migrations"
var (
ErrNilConfig = fmt.Errorf("no config")
ErrNoDatabaseName = fmt.Errorf("no database name")
)
type Config struct {
MigrationsTable string
DatabaseName string
}
type Redshift struct {
isLocked atomic.Bool
conn *sql.Conn
db *sql.DB
// Open and WithInstance need to guarantee that config is never nil
config *Config
}
func WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {View on GitHub (pinned to 01a9643f14)
Solutions
- Pass a non-nil &redshift.Config{DatabaseName: ..., MigrationsTable: redshift.DefaultMigrationsTable}
- Use the Open(dsn) entry point so the config is derived from the URL automatically
- Guard call sites with a nil check on config before invoking WithInstance
Example fix
// before
d, err := redshift.WithInstance(instance, nil)
// after
d, err := redshift.WithInstance(instance, &redshift.Config{
DatabaseName: "analytics",
MigrationsTable: redshift.DefaultMigrationsTable,
}) Defensive patterns
Strategy: validation
Validate before calling
func validateRedshiftConfig(cfg *redshift.Config) error {
if cfg == nil {
return errors.New("redshift config must not be nil")
}
if cfg.MigrationsTable == "" {
cfg.MigrationsTable = redshift.DefaultMigrationsTable
}
return nil
} Type guard
func hasConfig(cfg *redshift.Config) bool { return cfg != nil } Prevention
- Wrap redshift.WithInstance in a helper that requires a config and applies defaults
- Prefer Open(dsn) for URL-driven setups
- Check for nil config in code review checklists for driver integration
When it happens
Trigger: Calling redshift.WithInstance(instance, nil) or redshift.WithConnection(conn, nil).
Common situations: Programmatic driver construction embedded in another tool; copying postgres driver examples where the config was built elsewhere and passing nil as a placeholder.
Related errors
- no config
- no database name
- URL cannot be empty
- "%s" MigrationsTable contains too many dot characters
- x-migrations-table must be quoted (for instance '"migrate"."
AI-assisted analysis of golang-migrate/migrate@01a9643f14 (2026-09-02).
Data as JSON: /api/errors/49967d19c5c65501.
Report an issue: GitHub.