{"record":{"id":"6350670a0eb2ec2d","repo":"golang-migrate/migrate","slug":"no-database-name-635067","errorCode":null,"errorMessage":"no database name","messagePattern":"no database name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/sqlite3/sqlite3.go","lineNumber":26,"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/mattn/go-sqlite3\"\n)\n\nfunc init() {\n\tdatabase.Register(\"sqlite3\", &Sqlite{})\n}\n\nvar DefaultMigrationsTable = \"schema_migrations\"\nvar (\n\tErrDatabaseDirty  = fmt.Errorf(\"database is dirty\")\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\tNoTxWrap        bool\n}\n\ntype Sqlite struct {\n\tdb       *sql.DB\n\tisLocked atomic.Bool\n\n\tconfig *Config\n}\n\nfunc WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {\n\tif config == nil {\n\t\treturn nil, ErrNilConfig","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/sqlite3/sqlite3.go#L8-L44","documentation":"ErrNoDatabaseName in the sqlite3 migrate driver is returned by WithInstance, Open, or WithConnection when the resolved database name is empty. For sqlite3 this corresponds to the database file path (purl.Path) being blank, so migrations cannot be recorded.","triggerScenarios":"Open-ing a URL like 'sqlite3://' or 'sqlite3://?x-no-tx-wrap=true' with no path, or WithInstance where config.DatabaseName was not set.","commonSituations":"Building the connection URL from env vars that are empty or unset; URL parsing dropping the path; forgetting the file name when switching from a DSN string to a parsed URL.","solutions":["Include the database file path in the URL: sqlite3://path/to/db.sqlite3","Set config.DatabaseName when calling WithInstance/WithConnection","Verify the env/flag that supplies the path is populated before opening"],"exampleFix":"// before\nd, err := migrate.Open(\"sqlite3://\")\n// after\nd, err := migrate.Open(\"sqlite3://data/app.db\")","handlingStrategy":"validation","validationCode":"if dbPath == \"\" {\n    return errors.New(\"sqlite3 URL must include the database file path\")\n}\nd, err := migrate.Open(\"sqlite3://\" + dbPath)","typeGuard":"func hasDatabaseName(path string) bool { return strings.TrimSpace(path) != \"\" }","tryCatchPattern":null,"preventionTips":["Validate the URL/path from env vars before calling Open","Use os.Stat on the sqlite file when you expect an existing DB","Log the fully assembled URL (redacting credentials) in startup diagnostics"],"tags":["go","sqlite3","database","migration","missing-database-name"],"backgroundTag":"missing-database-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}