From fca2879fe35890c9277c44fdb6fc435c2a77bdbb Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Tue, 19 Aug 2025 10:55:09 +0000 Subject: [PATCH] [Bugfix] Fix AnyPB Parsing in Meta Service --- CHANGELOG.md | 1 + integrations/meta/v1/impl.go | 3 +-- integrations/meta/v1/object.go | 7 +++++-- integrations/meta/v1/service_test.go | 24 ++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 999001f33..f51ae0970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - (Feature) Add CA Certificates - (Feature) Chart By Tag filter - (Feature) Add Gateway Config condition +- (Bugfix) Fix AnyPB Parsing in Meta Service ## [1.3.0](https://github.com/arangodb/kube-arangodb/tree/1.3.0) (2025-08-01) - (Feature) (Platform) Storage Debug diff --git a/integrations/meta/v1/impl.go b/integrations/meta/v1/impl.go index 0de827fd9..4fddf3dca 100644 --- a/integrations/meta/v1/impl.go +++ b/integrations/meta/v1/impl.go @@ -39,7 +39,6 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/cache" "github.com/arangodb/kube-arangodb/pkg/util/errors" - ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc" "github.com/arangodb/kube-arangodb/pkg/util/svc" ) @@ -129,7 +128,7 @@ func (i *implementation) Set(ctx context.Context, req *pbMetaV1.SetRequest) (*pb obj.Key = key obj.Rev = req.Revision - obj.Object = ugrpc.NewGRPC(req.GetObject()) + obj.Object.Object = req.GetObject() if err := i.cache.Put(ctx, key, &obj); err != nil { if shared.IsPreconditionFailed(err) { diff --git a/integrations/meta/v1/object.go b/integrations/meta/v1/object.go index e48c4a3a5..62d181ad6 100644 --- a/integrations/meta/v1/object.go +++ b/integrations/meta/v1/object.go @@ -28,7 +28,6 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" pbMetaV1 "github.com/arangodb/kube-arangodb/integrations/meta/v1/definition" - ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc" ) type Object struct { @@ -37,7 +36,11 @@ type Object struct { Meta *ObjectMeta `json:"meta,omitempty"` - Object ugrpc.GRPC[*anypb.Any] `json:"object"` + Object ObjectProto `json:"object,omitempty"` +} + +type ObjectProto struct { + Object *anypb.Any `json:"Object,omitempty"` } func (o *Object) SetKey(s string) { diff --git a/integrations/meta/v1/service_test.go b/integrations/meta/v1/service_test.go index 732c32811..695979fe3 100644 --- a/integrations/meta/v1/service_test.go +++ b/integrations/meta/v1/service_test.go @@ -22,6 +22,7 @@ package v1 import ( "context" + "encoding/json" "testing" "github.com/stretchr/testify/require" @@ -32,6 +33,29 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc" ) +func Test_Types(t *testing.T) { + z := `{ + "meta": { + "updatedAt": "2025-07-07T15:13:09Z" + }, + "object": { + "Object": { + "type_url": "type.googleapis.com/arangodb_platform_internal.metadata_store.GenAiProjectNames", + "value": "ChV0ZXN0X3Byb2plY3RfNmVhYWM3MjM=" + } + } +}` + + var obj Object + + require.NoError(t, json.Unmarshal([]byte(z), &obj)) + + n, err := json.Marshal(obj) + require.NoError(t, err) + + require.JSONEq(t, z, string(n)) +} + func Handler(t *testing.T, ctx context.Context, mods ...util.ModR[Configuration]) svc.Handler { handler, err := New(ctx, NewConfiguration().With(mods...)) require.NoError(t, err)