vitessio/vitess · error

unsupported in FakeSrvTopo

Error message

unsupported in FakeSrvTopo

What it means

FakeSrvTopo is a lightweight test double for the srvtopo Server interface that only supports GetSrvKeyspace/GetSrvVSchema-style lookups. Streaming watch APIs (WatchSrvKeyspace, WatchSrvVSchema) are intentionally unimplemented and panic — the fake cannot deliver watch callbacks.

Source

Thrown at go/vt/srvtopo/fakesrvtopo/fakesrvtopo.go:60

	}
	if f.SrvKeyspaceNamesOutput == nil {
		return nil, nil
	}
	return f.SrvKeyspaceNamesOutput[cell], nil
}

func (f *FakeSrvTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
	if f.SrvKeyspaceError != nil && f.SrvKeyspaceError[cell] != nil && f.SrvKeyspaceError[cell][keyspace] != nil {
		return nil, f.SrvKeyspaceError[cell][keyspace]
	}
	if f.SrvKeyspaceOutput == nil || f.SrvKeyspaceOutput[cell] == nil {
		return nil, nil
	}
	return f.SrvKeyspaceOutput[cell][keyspace], nil
}

func (f *FakeSrvTopo) WatchSrvKeyspace(ctx context.Context, cell, keyspace string, callback func(*topodatapb.SrvKeyspace, error) bool) {
	panic("unsupported in FakeSrvTopo")
}

func (f *FakeSrvTopo) WatchSrvVSchema(ctx context.Context, cell string, callback func(*vschemapb.SrvVSchema, error) bool) {
	panic("unsupported in FakeSrvTopo")
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Use a full topo implementation (memorytopo or the real topo server) in tests that exercise watch paths
  2. Implement WatchSrvKeyspace in a local fake/test double that invokes the callback
  3. Refactor the code under test to fetch via GetSrvKeyspace instead of watching

Example fix

// before
ts := srvtopo.NewWatchSrvTopoServer(fakesrvtopo.New())
// after
ts := srvtopo.NewWatchSrvTopoServer(memorytopo.NewServer(ctx, "cell1"))
Defensive patterns

Strategy: validation

Validate before calling

func fakeSupportsWatch(f *srvtopo.Server) bool {
    _, ok := (*f).(*fakesrvtopo.FakeSrvTopo)
    return !ok
}

Type guard

func supportsWatch(s srvtopo.Server) bool {
    _, isFake := s.(*fakesrvtopo.FakeSrvTopo)
    return !isFake
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        if s, ok := r.(string); ok && s == "unsupported in FakeSrvTopo" {
            t.Skip("FakeSrvTopo does not support WatchSrvKeyspace")
        }
        panic(r)
    }
}()

Prevention

When it happens

Trigger: Running code that calls srvtopo.Server.WatchSrvKeyspace (e.g. VTGate watch-based keyspace refresh, discovery code paths) against a FakeSrvTopo instance.

Common situations: Unit or e2e-style tests wiring a component into FakeSrvTopo where the production code path uses watches instead of polling gets; enabling watch features in test flags.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/d96b8899a08d0839. Report an issue: GitHub.