From ffe3c155b49b5b90aef79eba44b0df652b2191e4 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Mon, 16 Oct 2023 16:28:38 -0700 Subject: [PATCH] Handle nil context fields, not just a nil context Found while testing https://github.com/crossplane-contrib/function-patch-and-transform/pull/17 Signed-off-by: Nic Cope --- response/response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/response/response.go b/response/response.go index 5792fc7..75ee96e 100644 --- a/response/response.go +++ b/response/response.go @@ -47,7 +47,7 @@ func To(req *v1beta1.RunFunctionRequest, ttl time.Duration) *v1beta1.RunFunction // SetContextKey sets context to the supplied key. func SetContextKey(rsp *v1beta1.RunFunctionResponse, key string, v *structpb.Value) { - if rsp.Context == nil { + if rsp.GetContext().GetFields() == nil { rsp.Context = &structpb.Struct{Fields: make(map[string]*structpb.Value)} } rsp.Context.Fields[key] = v