{"record":{"id":"ddf1aa65e60d7ceb","repo":"golang-migrate/migrate","slug":"no-config","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/cassandra/cassandra.go","lineNumber":32,"sourceCode":"\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/golang-migrate/migrate/v4/database/multistmt\"\n)\n\nfunc init() {\n\tdb := new(Cassandra)\n\tdatabase.Register(\"cassandra\", db)\n}\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n)\n\nvar DefaultMigrationsTable = \"schema_migrations\"\n\nvar (\n\tErrNilConfig     = errors.New(\"no config\")\n\tErrNoKeyspace    = errors.New(\"no keyspace provided\")\n\tErrDatabaseDirty = errors.New(\"database is dirty\")\n\tErrClosedSession = errors.New(\"session is closed\")\n)\n\ntype Config struct {\n\tMigrationsTable       string\n\tKeyspaceName          string\n\tMultiStatementEnabled bool\n\tMultiStatementMaxSize int\n}\n\ntype Cassandra struct {\n\tsession  *gocql.Session\n\tisLocked atomic.Bool\n\n\t// Open and WithInstance need to guarantee that config is never nil\n\tconfig *Config","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/cassandra/cassandra.go#L14-L50","documentation":"ErrNilConfig is returned by the Cassandra driver's WithInstance and WithConnection constructors when the *Config argument is nil. The driver requires a Config (at minimum KeyspaceName) to operate, and dereferencing a nil config would panic, so the library fails fast with this sentinel error. It signals a programming mistake by the caller, not a runtime/database failure.","triggerScenarios":"Calling database/cassandra WithInstance(session, nil) or WithConnection(conn, nil); also building a driver programmatically and forgetting to populate the config struct (empty or zero-value pointer passed in).","commonSituations":"Constructing the driver in code without a config file (e.g. omitting the 'x-migrations-table' style config or the cassandra:// URL query params), refactorings where a Config variable became nil, or test harnesses that pass nil placeholders.","solutions":["Pass a non-nil *cassandra.Config (set KeyspaceName at minimum) to WithInstance/WithConnection.","Open via the connection URL 'cassandra://host:9042/keyspace' so the driver parses and builds the config for you.","Check for nil config in your own wrapper before calling the driver and fail with a clearer message."],"exampleFix":"// before\ndriver, err := cassandra.WithInstance(session, nil)\n// after\ncfg := &cassandra.Config{KeyspaceName: \"my_keyspace\"}\ndriver, err := cassandra.WithInstance(session, cfg)","handlingStrategy":"validation","validationCode":"if config == nil {\n    return fmt.Errorf(\"cassandra driver requires a non-nil *cassandra.Config\")\n}","typeGuard":"func hasConfig(cfg *cassandra.Config) bool { return cfg != nil }","tryCatchPattern":"driver, err := cassandra.WithInstance(session, cfg)\nif err != nil {\n    if errors.Is(err, cassandra.ErrNilConfig) {\n        return fmt.Errorf(\"driver setup: config was not provided: %w\", err)\n    }\n    return err\n}","preventionTips":["Always construct Config explicitly at driver-creation time, never reuse a possibly-nil variable.","Prefer migrate.New with a full cassandra:// URL so config is parsed for you.","Add a unit test asserting your setup function never passes a nil config."],"tags":["go","configuration","cassandra","go-migrate"],"backgroundTag":"missing-configuration","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}