{"record":{"id":"11c7871c58dcac54","repo":"golang-migrate/migrate","slug":"no-config-11c787","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/pgx/pgx.go","lineNumber":48,"sourceCode":")\n\nfunc init() {\n\tdb := Postgres{}\n\tdatabase.Register(\"pgx\", &db)\n\tdatabase.Register(\"pgx4\", &db)\n}\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMigrationsTable       = \"schema_migrations\"\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n\tDefaultLockTable             = \"schema_lock\"\n\tDefaultLockStrategy          = LockStrategyAdvisory\n)\n\nvar (\n\tErrNilConfig      = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName = fmt.Errorf(\"no database name\")\n\tErrNoSchema       = fmt.Errorf(\"no schema\")\n\tErrDatabaseDirty  = fmt.Errorf(\"database is dirty\")\n)\n\ntype Config struct {\n\tMigrationsTable       string\n\tDatabaseName          string\n\tSchemaName            string\n\tLockTable             string\n\tLockStrategy          string\n\tmigrationsSchemaName  string\n\tmigrationsTableName   string\n\tStatementTimeout      time.Duration\n\tMigrationsTableQuoted bool\n\tMultiStatementEnabled bool\n\tMultiStatementMaxSize int\n}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/pgx/pgx.go#L30-L66","documentation":"ErrNilConfig is the pgx (Postgres) driver's sentinel meaning WithInstance or WithConnection was given a nil *Config. The driver guarantees its internal config is never nil and therefore rejects a nil argument up front instead of dereferencing it. Declared at database/pgx/pgx.go:48; raised in WithInstance (line 79-81) and WithConnection.","triggerScenarios":"Calling pgx.WithInstance(db, nil) or pgx.WithConnection(conn, nil); passing a *Config that is nil because an earlier constructor/parse step failed and its error was ignored.","commonSituations":"Building migrations in a wiring layer where Config is produced conditionally; upgrading code that previously used a non-pointer Config; test scaffolding that forgets to construct a Config.","solutions":["Pass a valid &pgx.Config{} with at least DatabaseName or rely on WithInstance to auto-detect it","Handle the error from your config-construction function so nil never reaches WithInstance","Add an explicit nil check for the *Config at your application boundary"],"exampleFix":"// before\nvar cfg *pgx.Config\ndrv, err := pgx.WithInstance(db, cfg) // nil\n// after\ncfg := &pgx.Config{ DatabaseName: \"app\" }\ndrv, err := pgx.WithInstance(db, cfg)","handlingStrategy":"validation","validationCode":"func validatePgxConfig(cfg *pgx.Config) error {\n    if cfg == nil {\n        return errors.New(\"pgx config must not be nil; use &pgx.Config{} for defaults\")\n    }\n    return nil\n}","typeGuard":"func hasPgxConfig(cfg *pgx.Config) bool { return cfg != nil }","tryCatchPattern":"drv, err := pgx.WithInstance(db, cfg)\nif errors.Is(err, pgx.ErrNilConfig) {\n    return fmt.Errorf(\"pgx: nil config passed; construct &pgx.Config{}: %w\", err)\n}","preventionTips":["Default to &pgx.Config{} instead of a nil *Config","Propagate and handle errors from any function that returns (*pgx.Config, error)","Add a nil check in the code path that instantiates the migration driver"],"tags":["postgres","pgx","configuration","nil-check","driver-init"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}