{"record":{"id":"49967d19c5c65501","repo":"golang-migrate/migrate","slug":"no-config-49967d","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/redshift/redshift.go","lineNumber":29,"sourceCode":"\tnurl \"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync/atomic\"\n\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/lib/pq\"\n)\n\nfunc init() {\n\tdb := Redshift{}\n\tdatabase.Register(\"redshift\", &db)\n}\n\nvar DefaultMigrationsTable = \"schema_migrations\"\n\nvar (\n\tErrNilConfig      = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName = fmt.Errorf(\"no database name\")\n)\n\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n}\n\ntype Redshift struct {\n\tisLocked atomic.Bool\n\tconn     *sql.Conn\n\tdb       *sql.DB\n\n\t// Open and WithInstance need to guarantee that config is never nil\n\tconfig *Config\n}\n\nfunc WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/redshift/redshift.go#L11-L47","documentation":"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.","triggerScenarios":"Calling redshift.WithInstance(instance, nil) or redshift.WithConnection(conn, nil).","commonSituations":"Programmatic driver construction embedded in another tool; copying postgres driver examples where the config was built elsewhere and passing nil as a placeholder.","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"],"exampleFix":"// before\nd, err := redshift.WithInstance(instance, nil)\n// after\nd, err := redshift.WithInstance(instance, &redshift.Config{\n    DatabaseName:    \"analytics\",\n    MigrationsTable: redshift.DefaultMigrationsTable,\n})","handlingStrategy":"validation","validationCode":"func validateRedshiftConfig(cfg *redshift.Config) error {\n    if cfg == nil {\n        return errors.New(\"redshift config must not be nil\")\n    }\n    if cfg.MigrationsTable == \"\" {\n        cfg.MigrationsTable = redshift.DefaultMigrationsTable\n    }\n    return nil\n}","typeGuard":"func hasConfig(cfg *redshift.Config) bool { return cfg != nil }","tryCatchPattern":null,"preventionTips":["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"],"tags":["redshift","configuration","nil-pointer","validation"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}