{"record":{"id":"9f53696915f18573","repo":"golang-migrate/migrate","slug":"no-config-9f5369","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/clickhouse/clickhouse.go","lineNumber":26,"sourceCode":"\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/golang-migrate/migrate/v4/database/multistmt\"\n)\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMigrationsTable       = \"schema_migrations\"\n\tDefaultMigrationsTableEngine = \"TinyLog\"\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n\n\tErrNilConfig = fmt.Errorf(\"no config\")\n)\n\ntype Config struct {\n\tDatabaseName          string\n\tClusterName           string\n\tMigrationsTable       string\n\tMigrationsTableEngine string\n\tMultiStatementEnabled bool\n\tMultiStatementMaxSize int\n}\n\nfunc init() {\n\tdatabase.Register(\"clickhouse\", &ClickHouse{})\n}\n\nfunc WithInstance(conn *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/clickhouse/clickhouse.go#L8-L44","documentation":"The ClickHouse driver defines ErrNilConfig (\"no config\") and returns it from WithInstance, WithConnection, and extractCustomQueryParams when the *Config argument is nil. It signals that driver construction was attempted without any configuration object, so there is nothing to read database name, table, or engine settings from.","triggerScenarios":"Passing nil as the config to clickhouse.WithInstance(conn, nil) or clickhouse.WithConnection(conn, nil); calling extractCustomQueryParams with a nil config.","commonSituations":"Building a driver programmatically without calling clickhouse.Config or WithURL first; a config variable that was declared but never initialized; an early-return path that lost the config value.","solutions":["Construct a config first: use clickhouse.WithURL(dsn) which parses the DSN into a Config, or build &Config{...} manually and pass it to WithInstance.","Check for nil before calling WithInstance/WithConnection and return your own descriptive error.","Ensure the code path that was supposed to initialize the config actually ran (no early returns skipping initialization)."],"exampleFix":"// before\nch, err := clickhouse.WithInstance(conn, nil)\n// after\ncfg := &clickhouse.Config{DatabaseName: \"default\", MigrationsTable: clickhouse.DefaultMigrationsTable}\nch, err := clickhouse.WithInstance(conn, cfg)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n    return fmt.Errorf(\"clickhouse config must not be nil\")\n}","typeGuard":"func validClickhouseConfig(cfg *clickhouse.Config) bool {\n    return cfg != nil && cfg.MigrationsTable != \"\"\n}","tryCatchPattern":"ch, err := clickhouse.WithInstance(conn, cfg)\nif err != nil {\n    if errors.Is(err, clickhouse.ErrNilConfig) {\n        return fmt.Errorf(\"clickhouse driver requires a config; use clickhouse.WithURL\")\n    }\n    return err\n}","preventionTips":["Prefer clickhouse.WithURL(dsn) so the Config is always populated by the library.","If building Config manually, initialize it in one constructor and never pass bare nil.","Add a nil-check assertion in tests for every driver construction path."],"tags":["clickhouse","configuration","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"}