diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index 0b169d35aa29897e42f81ff02d19499879108755..a5d6a5fc3103d8e9d623c8691bb92ea4b1601761 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -8,6 +8,7 @@ import ( "github.com/openconfig/goyang/pkg/yang" "github.com/openconfig/ygot/ytypes" log "github.com/sirupsen/logrus" + "reflect" "strings" ) @@ -231,7 +232,13 @@ func (g *Gnmi) set(ctx context.Context, setOps []*gnmi.Operation, // Subscribe calls GNMI subscribe func (g *Gnmi) subscribe(ctx context.Context) error { ctx = gnmi.NewContext(ctx, &g.Options.Config) - opts := ctx.Value("opts").(*gnmi.SubscribeOptions) + opts, ok := ctx.Value(CtxKeyOpts).(*gnmi.SubscribeOptions) + if !ok{ + return &ErrInvalidTypeAssertion{ + v: reflect.TypeOf(ctx.Value(CtxKeyOpts)), + t: reflect.TypeOf(&gnmi.SubscribeOptions{}), + } + } go func() { log.WithFields(log.Fields{ "address": opts.Target,