diff --git a/server/egrpc/interceptor.go b/server/egrpc/interceptor.go index 83aa4959..e2d22c57 100644 --- a/server/egrpc/interceptor.go +++ b/server/egrpc/interceptor.go @@ -215,8 +215,10 @@ type ctxStoreStruct struct{} // CtxStoreSet 从ctx中尝试获取ctxStore,并往其中插入kv func CtxStoreSet(ctx context.Context, k string, v any) { - skv, _ := ctx.Value(ctxStoreStruct{}).(*ctxStore) - skv.kvs[k] = v + skv, ok := ctx.Value(ctxStoreStruct{}).(*ctxStore) + if ok { + skv.kvs[k] = v + } } func (c *Container) defaultUnaryServerInterceptor() grpc.UnaryServerInterceptor {