{"record":{"id":"d96b8899a08d0839","repo":"vitessio/vitess","slug":"unsupported-in-fakesrvtopo","errorCode":null,"errorMessage":"unsupported in FakeSrvTopo","messagePattern":"unsupported in FakeSrvTopo","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/srvtopo/fakesrvtopo/fakesrvtopo.go","lineNumber":60,"sourceCode":"\t}\n\tif f.SrvKeyspaceNamesOutput == nil {\n\t\treturn nil, nil\n\t}\n\treturn f.SrvKeyspaceNamesOutput[cell], nil\n}\n\nfunc (f *FakeSrvTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {\n\tif f.SrvKeyspaceError != nil && f.SrvKeyspaceError[cell] != nil && f.SrvKeyspaceError[cell][keyspace] != nil {\n\t\treturn nil, f.SrvKeyspaceError[cell][keyspace]\n\t}\n\tif f.SrvKeyspaceOutput == nil || f.SrvKeyspaceOutput[cell] == nil {\n\t\treturn nil, nil\n\t}\n\treturn f.SrvKeyspaceOutput[cell][keyspace], nil\n}\n\nfunc (f *FakeSrvTopo) WatchSrvKeyspace(ctx context.Context, cell, keyspace string, callback func(*topodatapb.SrvKeyspace, error) bool) {\n\tpanic(\"unsupported in FakeSrvTopo\")\n}\n\nfunc (f *FakeSrvTopo) WatchSrvVSchema(ctx context.Context, cell string, callback func(*vschemapb.SrvVSchema, error) bool) {\n\tpanic(\"unsupported in FakeSrvTopo\")\n}\n","sourceCodeStart":42,"sourceCodeEnd":66,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/srvtopo/fakesrvtopo/fakesrvtopo.go#L42-L66","documentation":"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.","triggerScenarios":"Running code that calls srvtopo.Server.WatchSrvKeyspace (e.g. VTGate watch-based keyspace refresh, discovery code paths) against a FakeSrvTopo instance.","commonSituations":"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.","solutions":["Use a full topo implementation (memorytopo or the real topo server) in tests that exercise watch paths","Implement WatchSrvKeyspace in a local fake/test double that invokes the callback","Refactor the code under test to fetch via GetSrvKeyspace instead of watching"],"exampleFix":"// before\nts := srvtopo.NewWatchSrvTopoServer(fakesrvtopo.New())\n// after\nts := srvtopo.NewWatchSrvTopoServer(memorytopo.NewServer(ctx, \"cell1\"))","handlingStrategy":"validation","validationCode":"func fakeSupportsWatch(f *srvtopo.Server) bool {\n    _, ok := (*f).(*fakesrvtopo.FakeSrvTopo)\n    return !ok\n}","typeGuard":"func supportsWatch(s srvtopo.Server) bool {\n    _, isFake := s.(*fakesrvtopo.FakeSrvTopo)\n    return !isFake\n}","tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if s, ok := r.(string); ok && s == \"unsupported in FakeSrvTopo\" {\n            t.Skip(\"FakeSrvTopo does not support WatchSrvKeyspace\")\n        }\n        panic(r)\n    }\n}()","preventionTips":["Use memorytopo or a real topo server whenever tests exercise watch-based code paths","Audit which srvtopo methods the code under test calls before choosing FakeSrvTopo","Extend the fake (locally) to invoke callbacks if watch support is needed in tests"],"tags":["srvtopo","test-double","unimplemented","panic","watch"],"backgroundTag":"unimplemented-method","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}