weaviate/weaviate · error

Memtable::getMap(): %w

Error message

Memtable::getMap(): %w

What it means

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.

Source

Thrown at adapters/repos/db/lsmkv/memtable.go:527

	v, err := m.keyMulti.get(key)
	if err != nil {
		return nil, err
	}
	out := make([][]byte, len(v))
	for i := range v {
		out[i] = v[i].value
	}

	return out, nil
}

func (m *Memtable) getMap(key []byte) ([]MapPair, error) {
	start := time.Now()
	defer m.metrics.observeGetMap(start.UnixNano())

	if err := m.checkStrategy(StrategyMapCollection, StrategyInverted); err != nil {
		return nil, fmt.Errorf("Memtable::getMap(): %w", err)
	}

	m.RLock()
	defer m.RUnlock()

	v, err := m.keyMap.get(key)
	if err != nil {
		return nil, err
	}

	return v, nil
}

func (m *Memtable) append(key []byte, values []value) error {
	start := time.Now()
	defer m.metrics.observeAppend(start.UnixNano())

	if err := m.checkStrategy(StrategySetCollection, StrategyMapCollection); err != nil {

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Reopen the bucket with lsmkv.WithStrategy(lsmkv.StrategyMapCollection) (or StrategyInverted for inverted index buckets).
  2. Confirm which strategy the bucket was originally created with and always pass it at open time.
  3. Use GetCollection on SetCollection buckets instead of MapList when the data is not map-shaped.
  4. Read the wrapped error text ('strategy X expected, got Y') to identify the actual configured strategy.

Example fix

// before
bucket, _ := lsmkv.NewBucket(dir, lsmkv.WithStrategy(lsmkv.StrategySetCollection))
pairs, err := bucket.MapList(key) // fails

// after
bucket, _ := lsmkv.NewBucket(dir, lsmkv.WithStrategy(lsmkv.StrategyMapCollection))
pairs, err := bucket.MapList(key)
Defensive patterns

Strategy: validation

Validate before calling

if s := bucket.Strategy(); s != lsmkv.StrategyMapCollection && s != lsmkv.StrategyInverted {
    return fmt.Errorf("MapList unsupported on strategy %q", s)
}

Try / catch

pairs, err := bucket.MapList(key)
if err != nil && strings.Contains(err.Error(), "Memtable::getMap()") {
    return fmt.Errorf("bucket not map-strategy: %w", err)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/cb8c1be7eadad6c8. Report an issue: GitHub.