{"record":{"id":"cb8c1be7eadad6c8","repo":"weaviate/weaviate","slug":"memtable-getmap-w","errorCode":null,"errorMessage":"Memtable::getMap(): %w","messagePattern":"Memtable::getMap\\(\\): %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"adapters/repos/db/lsmkv/memtable.go","lineNumber":527,"sourceCode":"\n\tv, err := m.keyMulti.get(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tout := make([][]byte, len(v))\n\tfor i := range v {\n\t\tout[i] = v[i].value\n\t}\n\n\treturn out, nil\n}\n\nfunc (m *Memtable) getMap(key []byte) ([]MapPair, error) {\n\tstart := time.Now()\n\tdefer m.metrics.observeGetMap(start.UnixNano())\n\n\tif err := m.checkStrategy(StrategyMapCollection, StrategyInverted); err != nil {\n\t\treturn nil, fmt.Errorf(\"Memtable::getMap(): %w\", err)\n\t}\n\n\tm.RLock()\n\tdefer m.RUnlock()\n\n\tv, err := m.keyMap.get(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn v, nil\n}\n\nfunc (m *Memtable) append(key []byte, values []value) error {\n\tstart := time.Now()\n\tdefer m.metrics.observeAppend(start.UnixNano())\n\n\tif err := m.checkStrategy(StrategySetCollection, StrategyMapCollection); err != nil {","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/lsmkv/memtable.go#L509-L545","documentation":"Memtable.getMap() is restricted to buckets using StrategyMapCollection or StrategyInverted. If the memtable's strategy is anything else (e.g. Replace or SetCollection), the read is rejected with this wrapped CheckExpectedStrategy error rather than returning wrong-shaped data, because map buckets store per-key MapPair collections with a different on-disk layout.","triggerScenarios":"Calling bucket.MapList() on a bucket created with WithStrategy(StrategyReplace) or WithStrategy(StrategySetCollection), e.g. reading BM25-frequency (map) data from a bucket that was opened without WithStrategy(StrategyMapCollection).","commonSituations":"Opening an inverted-index or map bucket with the default Replace strategy after a restart; wiring a shard property to the wrong bucket strategy; tests that create SetCollection buckets then attempt MapList.","solutions":["Reopen the bucket with lsmkv.WithStrategy(lsmkv.StrategyMapCollection) (or StrategyInverted for inverted index buckets).","Confirm which strategy the bucket was originally created with and always pass it at open time.","Use GetCollection on SetCollection buckets instead of MapList when the data is not map-shaped.","Read the wrapped error text ('strategy X expected, got Y') to identify the actual configured strategy."],"exampleFix":"// before\nbucket, _ := lsmkv.NewBucket(dir, lsmkv.WithStrategy(lsmkv.StrategySetCollection))\npairs, err := bucket.MapList(key) // fails\n\n// after\nbucket, _ := lsmkv.NewBucket(dir, lsmkv.WithStrategy(lsmkv.StrategyMapCollection))\npairs, err := bucket.MapList(key)","handlingStrategy":"validation","validationCode":"if s := bucket.Strategy(); s != lsmkv.StrategyMapCollection && s != lsmkv.StrategyInverted {\n    return fmt.Errorf(\"MapList unsupported on strategy %q\", s)\n}","typeGuard":null,"tryCatchPattern":"pairs, err := bucket.MapList(key)\nif err != nil && strings.Contains(err.Error(), \"Memtable::getMap()\") {\n    return fmt.Errorf(\"bucket not map-strategy: %w\", err)\n}","preventionTips":["Persist/lookup the intended strategy (map vs inverted vs set) before opening the bucket.","Use typed wrappers: only expose MapList behind a MapBucket interface created with the map strategy.","Add table-driven tests covering each strategy/accessor pair."],"tags":["lsmkv","go","bucket-strategy","read-path"],"backgroundTag":"bucket-strategy-mismatch","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}