{"record":{"id":"f6693dc1179a6b84","repo":"golang-migrate/migrate","slug":"no-database-name-f6693d","errorCode":null,"errorMessage":"no database name","messagePattern":"no database name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/sqlcipher/sqlcipher.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/mutecomm/go-sqlcipher/v4\"\n)\n\nfunc init() {\n\tdatabase.Register(\"sqlcipher\", &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/sqlcipher/sqlcipher.go#L8-L44","documentation":"ErrNoDatabaseName is a sentinel error returned by the sqlcipher driver's WithInstance, Open, and WithConnection when the Config.DatabaseName (or the URL path) is empty. The driver uses the database name to manage the migrations state and cannot operate without it. It indicates the migration URL or config is incomplete.","triggerScenarios":"Calling sqlcipher.Open(\"sqlcipher://file.db\") with no path component, or WithInstance/WithConnection with a Config whose DatabaseName is \"\" — e.g. building the URL programmatically and the path/database name got dropped.","commonSituations":"Hand-written connection URL missing the database path after sqlcipher://; env var holding the DB name empty or unset; URL parsers stripping the path; using a config struct with the DatabaseName field forgotten.","solutions":["Set Config.DatabaseName (or ensure the URL includes a path: sqlcipher://path/to/db.sqlite) before constructing the driver.","Validate the database name is non-empty in your own config loading code and fail fast with a clear message.","Check the env var / config file that supplies the database name is actually populated in the deployment environment."],"exampleFix":"// before\ncfg := &sqlcipher.Config{}\nd, err := sqlcipher.WithInstance(db, cfg) // ErrNoDatabaseName\n// after\ncfg := &sqlcipher.Config{\n    DatabaseName: \"data/app.db\",\n}\nd, err := sqlcipher.WithInstance(db, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil || strings.TrimSpace(cfg.DatabaseName) == \"\" {\n    return fmt.Errorf(\"sqlcipher requires a non-empty DatabaseName\")\n}\n// or for URLs: ensure a path exists\nu, _ := url.Parse(dsn)\nif u.Path == \"\" { return fmt.Errorf(\"migration URL missing database path: %s\", dsn) }","typeGuard":"func hasDatabaseName(cfg *sqlcipher.Config) bool {\n    return cfg != nil && strings.TrimSpace(cfg.DatabaseName) != \"\"\n}","tryCatchPattern":"if err != nil {\n    if errors.Is(err, sqlcipher.ErrNoDatabaseName) {\n        return fmt.Errorf(\"check migration DSN/config: database name is required: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate the DSN has a path component before handing it to migrate.","Fail at startup if the env var holding the DB name is empty.","Keep DSN construction in one tested helper function."],"tags":["sqlcipher","sqlite","config","missing-database-name","go"],"backgroundTag":"missing-database-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}