{"record":{"id":"ad46d2a9fff01145","repo":"golang-migrate/migrate","slug":"no-config-ad46d2","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/sqlcipher/sqlcipher.go","lineNumber":25,"sourceCode":"\t\"io\"\n\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 {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/sqlcipher/sqlcipher.go#L7-L43","documentation":"ErrNilConfig is a sentinel error returned by the sqlcipher driver's WithInstance and WithConnection when the *Config argument passed in is nil. The driver requires a Config (at minimum a database name / migrations table) to construct the Driver. It is a programming error, not a runtime condition.","triggerScenarios":"Calling sqlcipher.WithInstance(db, nil) or sqlcipher.WithConnection(conn, nil) — passing a nil *Config pointer directly to the driver constructor.","commonSituations":"Copy-pasted driver setup code where the Config struct literal was deleted or commented out; building config conditionally and the nil branch being reached; wiring frameworks (DI) that inject a nil config when a config file/env was missing.","solutions":["Pass a non-nil *sqlcipher.Config to WithInstance/WithConnection, e.g. &sqlcipher.Config{DatabaseName: \"mydb\", MigrationsTable: sqlcipher.DefaultMigrationsTable}.","If config is built from env/file, validate it is non-nil before calling the driver constructor.","Use migrate.New/sourcefile://... or Open with a URL instead, which builds the config internally."],"exampleFix":"// before\nd, err := sqlcipher.WithInstance(db, nil)\n// after\ncfg := &sqlcipher.Config{\n    DatabaseName:    \"app\",\n    MigrationsTable: sqlcipher.DefaultMigrationsTable,\n}\nd, err := sqlcipher.WithInstance(db, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n    return fmt.Errorf(\"sqlcipher config must not be nil\")\n}","typeGuard":"func hasConfig(cfg *sqlcipher.Config) bool { return cfg != nil }","tryCatchPattern":"d, err := sqlcipher.WithInstance(db, cfg)\nif err != nil {\n    if errors.Is(err, sqlcipher.ErrNilConfig) {\n        return fmt.Errorf(\"programming error: pass a *sqlcipher.Config: %w\", err)\n    }\n    return err\n}","preventionTips":["Always construct the Config literal at the call site of WithInstance/WithConnection.","Centralize driver setup in one helper so a nil config can't slip through.","Fail fast in config loading: return an error if the loaded config is nil."],"tags":["sqlcipher","sqlite","config","nil-pointer","go"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}