{"record":{"id":"661262e896bb81dd","repo":"golang-migrate/migrate","slug":"no-config-661262","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/sqlserver/sqlserver.go","lineNumber":28,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\t\"sync/atomic\"\n\n\t\"github.com/Azure/go-autorest/autorest/adal\"\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\tmssql \"github.com/microsoft/go-mssqldb\" // mssql support\n)\n\nfunc init() {\n\tdatabase.Register(\"sqlserver\", &SQLServer{})\n}\n\n// DefaultMigrationsTable is the name of the migrations table in the database\nvar DefaultMigrationsTable = \"schema_migrations\"\n\nvar (\n\tErrNilConfig                 = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName            = fmt.Errorf(\"no database name\")\n\tErrNoSchema                  = fmt.Errorf(\"no schema\")\n\tErrDatabaseDirty             = fmt.Errorf(\"database is dirty\")\n\tErrMultipleAuthOptionsPassed = fmt.Errorf(\"both password and useMsi=true were passed\")\n)\n\nvar lockErrorMap = map[int]string{\n\t-1:   \"The lock request timed out.\",\n\t-2:   \"The lock request was canceled.\",\n\t-3:   \"The lock request was chosen as a deadlock victim.\",\n\t-999: \"Parameter validation or other call error.\",\n}\n\n// Config for database\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n\tSchemaName      string","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/sqlserver/sqlserver.go#L10-L46","documentation":"ErrNilConfig is the sqlserver driver's sentinel error returned when a nil *Config is passed to WithInstance or WithConnection. Without a config the driver cannot determine the migrations table or schema.","triggerScenarios":"Calling sqlserver.WithInstance(db, nil) or WithConnection(conn, nil); code paths constructing the driver manually with a missing config.","commonSituations":"Programmatic driver setup in tests or embedded migrations; refactors dropping the config argument; copying an example that passes a zero value where a pointer was required.","solutions":["Pass &sqlserver.Config{} with the fields you need set (MigrationsTable, DatabaseName, SchemaName)","Prefer opening via URL (e.g. sqlserver://user:pass@host:port?database=...) so the driver builds the config","Audit the call site for a nil-returning config constructor"],"exampleFix":"// before\ndrv, err := sqlserver.WithInstance(db, nil)\n// after\ncfg := &sqlserver.Config{MigrationsTable: \"schema_migrations\"}\ndrv, err := sqlserver.WithInstance(db, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n    return errors.New(\"sqlserver driver requires a non-nil Config\")\n}\ndrv, err := sqlserver.WithInstance(db, cfg)","typeGuard":"func configProvided(cfg *sqlserver.Config) bool { return cfg != nil }","tryCatchPattern":null,"preventionTips":["Centralize sqlserver.Config construction in one factory function","Never pass nil pointer literals to WithInstance/WithConnection","Cover driver construction in a smoke test"],"tags":["go","sqlserver","database","migration","nil-config"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}