golang-migrate/migrate · error
no config
Error message
no config
What it means
ErrNilConfig is the Neo4j driver's sentinel meaning WithInstance/WithConnection was called with a nil *Config. These constructors dereference the config immediately (e.g. reading MigrationsLabel, MultiStatementMaxSize), so the library fails fast with this error instead of panicking. It is raised at database/neo4j/neo4j.go:30 and equivalent sentinels exist in cassandra/pgx/mysql drivers.
Source
Thrown at database/neo4j/neo4j.go:30
"github.com/golang-migrate/migrate/v4/database"
"github.com/golang-migrate/migrate/v4/database/multistmt"
"github.com/neo4j/neo4j-go-driver/neo4j"
)
func init() {
db := Neo4j{}
database.Register("neo4j", &db)
}
const DefaultMigrationsLabel = "SchemaMigration"
var (
StatementSeparator = []byte(";")
DefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB
)
var (
ErrNilConfig = fmt.Errorf("no config")
)
type Config struct {
MigrationsLabel string
MultiStatement bool
MultiStatementMaxSize int
}
type Neo4j struct {
driver neo4j.Driver
lock uint32
// Open and WithInstance need to guarantee that config is never nil
config *Config
}
func WithInstance(driver neo4j.Driver, config *Config) (database.Driver, error) {
if config == nil {View on GitHub (pinned to 01a9643f14)
Solutions
- Pass a non-nil &neo4j.Config{} (fields may be left at defaults) to WithInstance/WithConnection
- Check the error from whatever function builds your Config before using it
- In code that receives a *Config, guard with if cfg == nil before calling the driver
Example fix
// before
drv, err := neo4j.WithInstance(driver, nil)
// after
cfg := &neo4j.Config{ MigrationsLabel: "migration" }
drv, err := neo4j.WithInstance(driver, cfg) Defensive patterns
Strategy: validation
Validate before calling
func validateNeo4jConfig(cfg *neo4j.Config) error {
if cfg == nil {
return errors.New("neo4j config must not be nil")
}
return nil
} Type guard
func hasNeo4jConfig(cfg *neo4j.Config) bool { return cfg != nil } Try / catch
drv, err := neo4j.WithInstance(driver, cfg)
if errors.Is(err, neo4j.ErrNilConfig) {
return fmt.Errorf("neo4j: config was nil, check config construction: %w", err)
} Prevention
- Always construct Config with &neo4j.Config{...}, never assign nil
- Check errors from config-building helpers before using their result
- Guard with a nil check at the wiring boundary where the driver is created
When it happens
Trigger: Calling neo4j.WithInstance(driver, nil) or neo4j.WithConnection(session, nil); passing a Config variable that was declared but never initialized, or one that a factory function returned as nil on an error path that was ignored.
Common situations: Constructing the driver in a helper where the config is built conditionally; ignoring an earlier error so the *Config is still nil; refactoring that changed Config from value to pointer semantics.
Related errors
AI-assisted analysis of golang-migrate/migrate@01a9643f14 (2026-09-02).
Data as JSON: /api/errors/e1009e8bc167c9b5.
Report an issue: GitHub.