{"record":{"id":"bd21e1645a8c7760","repo":"golang-migrate/migrate","slug":"no-database-name-bd21e1","errorCode":null,"errorMessage":"no database name","messagePattern":"no database name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/redshift/redshift.go","lineNumber":30,"sourceCode":"\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) {\n\tif config == nil {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/redshift/redshift.go#L12-L48","documentation":"ErrNoDatabaseName is the redshift driver's sentinel returned when Config.DatabaseName is empty (WithInstance/WithConnection) or the Open URL has no database in its path. The driver must know which database to operate on for the migrations table and version tracking.","triggerScenarios":"redshift.Open(\"redshift://host:5439\") without a path; WithInstance/WithConnection with Config{DatabaseName: \"\"}.","commonSituations":"Reusing a postgres DSN template with the path stripped for redshift; environment-driven configs where DB_NAME is unset in the deploy target; misconfigured IaC templates.","solutions":["Add the database name to the URL path, e.g. redshift://user:pass@host:5439/dbname","Set Config.DatabaseName before calling WithInstance/WithConnection","Validate the database name at application startup before invoking the migrator"],"exampleFix":"// before\ndsn := fmt.Sprintf(\"redshift://%s:%s@%s:5439\", user, pass, host)\n// after\ndsn := fmt.Sprintf(\"redshift://%s:%s@%s:5439/%s\", user, pass, host, dbName)\nif dbName == \"\" {\n    return errors.New(\"redshift database name is required\")\n}","handlingStrategy":"validation","validationCode":"func requireRedshiftDatabaseName(cfg *redshift.Config) error {\n    if cfg == nil || cfg.DatabaseName == \"\" {\n        return errors.New(\"redshift: DatabaseName is required\")\n    }\n    return nil\n}","typeGuard":"func hasDatabaseName(cfg *redshift.Config) bool {\n    return cfg != nil && cfg.DatabaseName != \"\"\n}","tryCatchPattern":null,"preventionTips":["Validate the database name env var before building the DSN","Include /dbname in redshift URLs when using Open","Share one config-building function across environments so the path is never dropped"],"tags":["redshift","configuration","missing-parameter","validation"],"backgroundTag":"missing-database-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}