From 722e6c1e42c2597bb13f50160c446450d7581655 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 29 Apr 2025 21:20:27 +0200 Subject: [PATCH] test(integration): panic on internal errors --- internal/command/system_features.go | 2 +- internal/integration/client.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/command/system_features.go b/internal/command/system_features.go index b317ea93bb..851db56ab1 100644 --- a/internal/command/system_features.go +++ b/internal/command/system_features.go @@ -40,7 +40,7 @@ func (m *SystemFeatures) isEmpty() bool { func (c *Commands) SetSystemFeatures(ctx context.Context, f *SystemFeatures) (*domain.ObjectDetails, error) { if f.isEmpty() { - return nil, zerrors.ThrowInternal(nil, "COMMAND-Oop8a", "Errors.NoChangesFound") + return nil, zerrors.ThrowInvalidArgument(nil, "COMMAND-Oop8a", "Errors.NoChangesFound") } wm := NewSystemFeaturesWriteModel() if err := c.eventstore.FilterToQueryReducer(ctx, wm); err != nil { diff --git a/internal/integration/client.go b/internal/integration/client.go index e82a6bec55..5152d3f459 100644 --- a/internal/integration/client.go +++ b/internal/integration/client.go @@ -12,8 +12,10 @@ import ( "github.com/stretchr/testify/require" "github.com/zitadel/logging" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/structpb" @@ -72,9 +74,17 @@ type Client struct { SCIM *scim.Client } +// newClient creates a new Zitadel client that panics on each internal error. func newClient(ctx context.Context, target string) (*Client, error) { cc, err := grpc.NewClient(target, grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithUnaryInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + err := invoker(ctx, method, req, reply, cc, opts...) + if status.Convert(err).Code() == codes.Internal { + panic(err) + } + return err + }), ) if err != nil { return nil, err