{"record":{"id":"51da8a86df3cb922","repo":"golang-migrate/migrate","slug":"no-database-name-51da8a","errorCode":null,"errorMessage":"no database name","messagePattern":"no database name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/snowflake/snowflake.go","lineNumber":28,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\t\"sync/atomic\"\n\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/lib/pq\"\n\tsf \"github.com/snowflakedb/gosnowflake\"\n)\n\nfunc init() {\n\tdb := Snowflake{}\n\tdatabase.Register(\"snowflake\", &db)\n}\n\nvar DefaultMigrationsTable = \"schema_migrations\"\n\nvar (\n\tErrNilConfig          = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName     = fmt.Errorf(\"no database name\")\n\tErrNoPassword         = fmt.Errorf(\"no password\")\n\tErrNoSchema           = fmt.Errorf(\"no schema\")\n\tErrNoSchemaOrDatabase = fmt.Errorf(\"no schema/database name\")\n)\n\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n}\n\ntype Snowflake 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}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/snowflake/snowflake.go#L10-L46","documentation":"ErrNoDatabaseName (message \"no database name\") is declared in the Snowflake driver (snowflake.go:28) and returned when the database component of the DSN is missing or empty. In Open (snowflake.go:111-113), after the URL path is split on \"/\" the third segment must be a non-empty database name; it is also returned by WithInstance/WithConnection when Config.DatabaseName is empty. Snowflake requires an explicit database to run migrations against.","triggerScenarios":"URLs like snowflake://user:pass@account/schema/ (empty third path segment); WithInstance with Config where DatabaseName == \"\".","commonSituations":"DSNs templated for Postgres-style URLs (host/db) missing Snowflake's account/schema/database three-level path; env-var substitution producing an empty database segment.","solutions":["Provide the full three-level path: snowflake://user:pass@account/schema/database","Set DatabaseName in the Config when using WithInstance/WithConnection","Verify env-substituted DSNs don't collapse to an empty trailing segment","Validate the URL path length and non-empty segments before calling Open"],"exampleFix":"// before\nurl := \"snowflake://user:pass@acct/PUBLIC/\"\n// after\nurl := \"snowflake://user:pass@acct/PUBLIC/MYDB\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dsn)\nparts := strings.Split(u.Path, \"/\")\nif len(parts) < 3 || parts[2] == \"\" {\n    return fmt.Errorf(\"snowflake DSN must be .../schema/database; got path %q\", u.Path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include all three URL levels: account (host), schema, database","Verify env-substituted DSNs don't produce empty segments","Set Config.DatabaseName explicitly when using WithInstance"],"tags":["go","golang-migrate","snowflake","config","dsn"],"backgroundTag":"missing-database-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}