{"record":{"id":"0aa2c383fb8ba187","repo":"golang-migrate/migrate","slug":"no-config-0aa2c3","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/pgx/v5/pgx.go","lineNumber":39,"sourceCode":"\t\"github.com/jackc/pgerrcode\"\n\t\"github.com/jackc/pgx/v5/pgconn\"\n\t_ \"github.com/jackc/pgx/v5/stdlib\"\n)\n\nfunc init() {\n\tdb := Postgres{}\n\tdatabase.Register(\"pgx5\", &db)\n}\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMigrationsTable       = \"schema_migrations\"\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n)\n\nvar (\n\tErrNilConfig      = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName = fmt.Errorf(\"no database name\")\n\tErrNoSchema       = fmt.Errorf(\"no schema\")\n)\n\ntype Config struct {\n\tMigrationsTable       string\n\tDatabaseName          string\n\tSchemaName            string\n\tmigrationsSchemaName  string\n\tmigrationsTableName   string\n\tStatementTimeout      time.Duration\n\tMigrationsTableQuoted bool\n\tMultiStatementEnabled bool\n\tMultiStatementMaxSize int\n}\n\ntype Postgres struct {\n\t// Locking and unlocking need to use the same connection","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/pgx/v5/pgx.go#L21-L57","documentation":"ErrNilConfig is the sentinel error returned by the pgx v5 driver when a nil *Config is passed to WithInstance or WithConnection. The library requires a Config struct (at minimum nothing, but the pointer itself must be non-nil) to initialize defaults like the migrations table name. It exists so callers can use errors.Is to detect the misconfiguration.","triggerScenarios":"Calling pgxv5.WithInstance(conn, nil) or pgxv5.WithConnection(conn, nil) — i.e. passing a nil *pgxv5.Config pointer — commonly when a config-building function returns a nil pointer on an error path that the caller ignored.","commonSituations":"Refactoring code that previously took no config; a helper that conditionally returns nil Config; using a struct value that was declared as a pointer and never initialized; copying examples that omit Config creation.","solutions":["Pass a non-nil *pgxv5.Config, even an empty one: &pgxv5.Config{}.","Check whether WithInstance/WithConnection accepts nil and instead rely on Open(url) if you have no settings to provide.","Audit your config-construction path for functions that can return (nil, nil) and fix the error handling.","Use errors.Is(err, pgxv5.ErrNilConfig) in your call site to detect and log this specific misconfiguration."],"exampleFix":"// before\nvar cfg *pgxv5.Config\ndrv, err := pgxv5.WithInstance(conn, cfg) // ErrNilConfig\n// after\ncfg := &pgxv5.Config{MigrationsTable: \"schema_migrations\"}\ndrv, err := pgxv5.WithInstance(conn, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n    cfg = &pgxv5.Config{MigrationsTable: \"schema_migrations\"}\n}","typeGuard":"func hasConfig(c *pgxv5.Config) bool { return c != nil }","tryCatchPattern":"drv, err := pgxv5.WithInstance(conn, cfg)\nif err != nil {\n    if errors.Is(err, pgxv5.ErrNilConfig) {\n        return fmt.Errorf(\"programming error: Config must not be nil: %w\", err)\n    }\n    return err\n}","preventionTips":["Never return (nil, nil) from config-building helpers","Default to an empty &pgxv5.Config{} rather than a nil pointer","Prefer pgxv5.Open(url) when you have no custom settings"],"tags":["postgresql","nil-config","programming-error"],"backgroundTag":"nil-config-argument","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}