From 02498ce2787ef8d146c8e420096d54875d069bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muraru=20=C8=98tefan?= Date: Fri, 30 May 2025 16:58:10 +0300 Subject: [PATCH 1/2] fix: Correctly validate backend_options configuration --- state/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/client.go b/state/client.go index c9247778cc..4e4c39ca77 100644 --- a/state/client.go +++ b/state/client.go @@ -55,7 +55,7 @@ func NewConnectedClient(ctx context.Context, backendOpts *plugin.BackendOptions) // The state client is guaranteed to be non-nil (it defaults to the NoOpClient). // You must call Close() on the returned Client object. func NewConnectedClientWithOptions(ctx context.Context, backendOpts *plugin.BackendOptions, connOpts ConnectionOptions, clOpts ClientOptions) (Client, error) { - if backendOpts == nil { + if backendOpts == nil || backendOpts.Connection == "" || backendOpts.TableName == "" { return &NoOpClient{}, nil } From 5ec0193ec12b1b872de7c5a226d98c0dacc5f9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muraru=20=C8=98tefan?= Date: Fri, 30 May 2025 17:13:46 +0300 Subject: [PATCH 2/2] fix: error on incorrectly configured backend_options --- state/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/state/client.go b/state/client.go index 4e4c39ca77..cca64bbb41 100644 --- a/state/client.go +++ b/state/client.go @@ -55,10 +55,16 @@ func NewConnectedClient(ctx context.Context, backendOpts *plugin.BackendOptions) // The state client is guaranteed to be non-nil (it defaults to the NoOpClient). // You must call Close() on the returned Client object. func NewConnectedClientWithOptions(ctx context.Context, backendOpts *plugin.BackendOptions, connOpts ConnectionOptions, clOpts ClientOptions) (Client, error) { - if backendOpts == nil || backendOpts.Connection == "" || backendOpts.TableName == "" { + // backend_options missing or configured but empty + if backendOpts == nil || (backendOpts.Connection == "" && backendOpts.TableName == "") { return &NoOpClient{}, nil } + // backend_options configured incorrectly, e.g. missing connection or table_name + if backendOpts.Connection == "" || backendOpts.TableName == "" { + return nil, fmt.Errorf("backend_options must contain both connection and table_name: %v", backendOpts) + } + backendConn, err := grpc.NewClient(backendOpts.Connection, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultCallOptions(