{"record":{"id":"e0e67dc22e3a5001","repo":"golang-migrate/migrate","slug":"no-config-e0e67d","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/yugabytedb/yugabytedb.go","lineNumber":31,"sourceCode":"\n\t\"github.com/cenkalti/backoff/v4\"\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/jackc/pgconn\"\n\t\"github.com/jackc/pgerrcode\"\n\t\"github.com/lib/pq\"\n)\n\nconst (\n\tDefaultMaxRetryInterval    = time.Second * 15\n\tDefaultMaxRetryElapsedTime = time.Second * 30\n\tDefaultMaxRetries          = 10\n\tDefaultMigrationsTable     = \"migrations\"\n\tDefaultLockTable           = \"migrations_locks\"\n)\n\nvar (\n\tErrNilConfig          = errors.New(\"no config\")\n\tErrNoDatabaseName     = errors.New(\"no database name\")\n\tErrMaxRetriesExceeded = errors.New(\"max retries exceeded\")\n)\n\nfunc init() {\n\tdb := YugabyteDB{}\n\tdatabase.Register(\"yugabyte\", &db)\n\tdatabase.Register(\"yugabytedb\", &db)\n\tdatabase.Register(\"ysql\", &db)\n}\n\ntype Config struct {\n\tMigrationsTable     string\n\tLockTable           string\n\tForceLock           bool\n\tDatabaseName        string\n\tMaxRetryInterval    time.Duration\n\tMaxRetryElapsedTime time.Duration","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/yugabytedb/yugabytedb.go#L13-L49","documentation":"The golang-migrate yugabytedb driver returns ErrNilConfig ('no config') when a driver instance is created without a *Config. WithInstance, WithConnection (and WithConfig paths) require a non-nil config holding keyspace, migrations table, and retry settings; without one the driver cannot operate. It is a sentinel error (errors.New) so it can be compared with errors.Is.","triggerScenarios":"Calling database/yugabytedb.WithInstance(session, nil) or WithConnection(conn, nil) with a nil *Config; constructing the driver via database.Open with a driver that was handed a nil config.","commonSituations":"Passing a nil config variable that failed to initialize; refactoring code that used to build a Config; copying driver setup from another database package with a different signature; helper functions that return (config, err) and the nil value is forwarded unchecked.","solutions":["Build and pass a &yugabytedb.Config{} (with DatabaseName/KeyspaceName and Defaults, e.g. DefaultMigrationsTable) instead of nil.","Check config != nil before calling WithInstance/WithConnection and construct a default config when missing.","Compare with errors.Is(err, yugabytedb.ErrNilConfig) to confirm which guard fired and fix the call site.","If using Open, ensure the config that gets assembled from the URL is not empty (e.g. include the keyspace in the connection string)."],"exampleFix":"// before\nm, err := yugabytedb.WithInstance(session, nil)\n// after\ncfg := &yugabytedb.Config{MigrationsTable: yugabytedb.DefaultMigrationsTable, DatabaseName: \"mydb\"}\nm, err := yugabytedb.WithInstance(session, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n\treturn nil, errors.New(\"yugabytedb: config is required\")\n}\ndriver, err := yugabytedb.WithInstance(session, cfg)","typeGuard":"func validConfig(cfg *yugabytedb.Config) bool { return cfg != nil }","tryCatchPattern":null,"preventionTips":["Always construct a Config explicitly; never pass a possibly-nil variable straight into WithInstance/WithConnection","Centralize driver construction in one helper that fills defaults (MigrationsTable, retry settings)","Use errors.Is(err, yugabytedb.ErrNilConfig) in error handling to distinguish it from other failures"],"tags":["go","golang-migrate","yugabytedb","nil-config"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}