{"record":{"id":"5d6d050a79337422","repo":"golang-migrate/migrate","slug":"no-keyspace-provided","errorCode":null,"errorMessage":"no keyspace provided","messagePattern":"no keyspace provided","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/cassandra/cassandra.go","lineNumber":33,"sourceCode":"\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\n}","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/cassandra/cassandra.go#L15-L51","documentation":"ErrNoKeyspace is returned when the Cassandra driver cannot determine which keyspace to run migrations in. WithInstance returns it when config.KeyspaceName is empty; Open returns it when the cassandra:// URL has no keyspace in its path. The migrations table must live inside a keyspace, so the driver refuses to proceed.","triggerScenarios":"WithInstance called with Config{KeyspaceName: \"\"}; Open called with a URL like 'cassandra://host:9042/' (empty path) or a URL missing the keyspace path segment entirely.","commonSituations":"Hand-writing a DSN and forgetting the trailing '/keyspace' segment, env-var templating that left the keyspace blank, or building Config from flags where the keyspace flag was not provided.","solutions":["Append the keyspace to the URL: cassandra://127.0.0.1:9042/mykeyspace.","Set KeyspaceName in the *cassandra.Config when using WithInstance.","Verify the config value is loaded from your env/config file before calling the driver (non-empty check)."],"exampleFix":"// before\ndb, err := migrate.New(\"cassandra://127.0.0.1:9042\", \"file://migrations\")\n// after\ndb, err := migrate.New(\"cassandra://127.0.0.1:9042/my_keyspace\", \"file://migrations\")","handlingStrategy":"validation","validationCode":"if cfg == nil || cfg.KeyspaceName == \"\" {\n    return fmt.Errorf(\"cassandra keyspace is required\")\n}\nu, err := url.Parse(dsn)\nif err != nil || u.Path == \"\" {\n    return fmt.Errorf(\"cassandra DSN must include /keyspace\")\n}","typeGuard":null,"tryCatchPattern":"m, err := migrate.New(dsn, \"file://migrations\")\nif errors.Is(err, cassandra.ErrNoKeyspace) {\n    return fmt.Errorf(\"check DSN: expected cassandra://host:9042/keyspace\")\n}","preventionTips":["Keep the keyspace in a single env var and template it into the DSN.","Smoke-test the DSN with url.Parse and assert a non-empty path at startup.","Document the required DSN shape (cassandra://host:9042/keyspace) for your team."],"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"}