{"record":{"id":"33229c51634bbe2a","repo":"t8y2/dbx","slug":"cassandra-keyspace-not-found-s","errorCode":null,"errorMessage":"Cassandra keyspace not found: %s","messagePattern":"Cassandra keyspace not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/metadata.go","lineNumber":187,"sourceCode":"func (s *server) allKeyspaceMetadata() (map[string]*gocql.KeyspaceMetadata, error) {\n\tsession, err := s.runtime.sessionFor(\"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn session.AllKeyspaceMetadata()\n}\n\nfunc (s *server) keyspaceMetadata(schema string) (*gocql.KeyspaceMetadata, error) {\n\tsession, err := s.runtime.sessionFor(\"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmetadata, err := session.KeyspaceMetadata(schema)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif metadata == nil {\n\t\treturn nil, fmt.Errorf(\"Cassandra keyspace not found: %s\", schema)\n\t}\n\treturn metadata, nil\n}\n\nfunc (s *server) tableMetadata(schema, table string) (*gocql.TableMetadata, error) {\n\tkeyspace, err := s.keyspaceMetadata(schema)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmetadata := keyspace.Tables[table]\n\tif metadata == nil {\n\t\treturn nil, fmt.Errorf(\"Cassandra table not found: %s.%s\", schema, table)\n\t}\n\treturn metadata, nil\n}\n\nfunc (s *server) listDatabases() ([]databaseInfo, error) {\n\tmetadata, err := s.allKeyspaceMetadata()","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/metadata.go#L169-L205","documentation":"This error is returned by keyspaceMetadata in the Cassandra driver after session.KeyspaceMetadata(schema) succeeds but yields a nil metadata object. It signals that the requested keyspace name does not exist in the cluster (or its metadata could not be resolved), so no schema information can be returned to tableMetadata/listTables callers.","triggerScenarios":"Calling ListTables, GetColumns, GetTableDDL or any metadata API with a keyspace name that does not exist in the Cassandra cluster; gocql's KeyspaceMetadata returns (nil, nil) for a missing keyspace and this driver converts that into an explicit error.","commonSituations":"Typo in the keyspace name; connecting without specifying a keyspace so an empty/default name is used; keyspace was dropped or renamed; environment mismatch (dev keyspace vs prod keyspace); case-sensitive keyspace names in system_schema.","solutions":["Verify the keyspace exists: run `DESCRIBE keyspaces;` in cqlsh or SELECT keyspace_name FROM system_schema.keyspaces;","Fix the keyspace name passed to the driver/API call, matching exact case (Cassandra keyspaces are case-sensitive when quoted)","Set a valid keyspace in the connection config so callers that omit one resolve to the intended keyspace","Create the missing keyspace if it should exist (CREATE KEYSPACE ...)"],"exampleFix":"// before\nmeta, err := srv.ListTables(ctx, \"sale\")\n// after\nmeta, err := srv.ListTables(ctx, \"sales\") // keyspace verified via SELECT keyspace_name FROM system_schema.keyspaces","handlingStrategy":"validation","validationCode":"var exists bool\nif err := session.Query(\"SELECT count(*) FROM system_schema.keyspaces WHERE keyspace_name = ?\", ks).Scan(&exists); err != nil || !exists {\n\treturn fmt.Errorf(\"keyspace %q does not exist\", ks)\n}","typeGuard":null,"tryCatchPattern":"meta, err := srv.ListTables(ctx, ks)\nif err != nil {\n\tif strings.Contains(err.Error(), \"Cassandra keyspace not found\") {\n\t\t// prompt user / fall back to default keyspace\n\t\treturn fmt.Errorf(\"keyspace %q not found; available: %v\", ks, listKeyspaces(session))\n\t}\n\treturn err\n}","preventionTips":["Always verify the keyspace exists in system_schema.keyspaces before metadata calls","Pin the keyspace in connection config per environment","Validate keyspace names with exact case checks before calling the driver","Keep keyspace names in one shared config constant rather than hard-coding strings"],"tags":["cassandra","metadata","keyspace","schema"],"backgroundTag":"keyspace-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}